12.3.3 Planar mapping (flattening projection)

Source: Internet
Author: User

12.3.3 Planar Mapping (flatteningprojection)

A planar map, which can generate sequence of elements for each element in the source collection, merging all return sequences. As we'll see shortly, this is the basic operation of defining other processing operations, including mapping and filtering. The unique feature of planar mapping is the ability to generate multiple output elements for each INPUT element.

Attention

In the LINQ library, this operation is called SelectMany. In a query expression, it is represented by multiple from clauses. As you can see from the name, it is similar to a Select operation, but can return multiple elements for each item in the source. The corresponding function in the F # Library is seq.collect. Here, the name implies implementation, just like calling the Seq.map function, generating sequences of sequences, and then calling Seq.concat to concatenate them together.

Let's take a look at an example that requires planar mapping, that is, it is not possible to write this example with a higher-order function, as in the previous section. Let's take a look at the implementation of the F # sequence expression, and then gradually modify the code to use the mapping.

12.3.3 Planar mapping (flattening projection)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.