문제

Given 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?

도움이 되었습니까?

해결책

You need to cast the result to a seq<int>:

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

alternatively you could use List.collect:

[2; 3; 4] |> List.collect iota
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top