Call IEnumerable.SelectMany

Considering this:

open System.Linq

let iota n = [0..(n-1)]

the following produces an error:

[2; 3; 4].SelectMany(fun n -> iota n)

Is there a way to pass function values ​​to SelectMany?

0
source share
1 answer

You need to pass the result to seq<int>:

[2; 3; 4].SelectMany(fun n -> iota n :> int seq)

alternatively you can use List.collect:

[2; 3; 4] |> List.collect iota
+4
source

Source: https://habr.com/ru/post/1538225/


All Articles