3 people like it.
Like the snippet!
Choose while function
A function that is like 'Seq.choose' but stops producing values as soon as the first 'None' value is produced.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
|
let chooseWhile f (input:seq<_>) =
seq { use en = input.GetEnumerator()
let mutable finished = false
while not finished do
if en.MoveNext() then
match f en.Current with
| None -> finished <- true
| Some v -> yield v
else
finished <- true }
|
val chooseWhile : f:('a -> 'b option) -> input:seq<'a> -> seq<'b>
Full name: Script.chooseWhile
val f : ('a -> 'b option)
val input : seq<'a>
Multiple items
val seq : sequence:seq<'T> -> seq<'T>
Full name: Microsoft.FSharp.Core.Operators.seq
--------------------
type seq<'T> = System.Collections.Generic.IEnumerable<'T>
Full name: Microsoft.FSharp.Collections.seq<_>
val en : System.Collections.Generic.IEnumerator<'a>
System.Collections.Generic.IEnumerable.GetEnumerator() : System.Collections.Generic.IEnumerator<'a>
val mutable finished : bool
val not : value:bool -> bool
Full name: Microsoft.FSharp.Core.Operators.not
System.Collections.IEnumerator.MoveNext() : bool
property System.Collections.Generic.IEnumerator.Current: 'a
union case Option.None: Option<'T>
union case Option.Some: Value: 'T -> Option<'T>
val v : 'b
More information