1 people like it.
Like the snippet!
Another successive enumeration
Applying functions on the n first elements
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
|
let sa = [ 1 .. 10 ]
let iter2 fs xs =
let apply1thenn fs =
let last = ref Unchecked.defaultof<_>
let unforget fs =
seq { for x in fs do last := x; yield x }
let rec forever f = seq { yield f; yield! forever f}
seq { yield! unforget fs
yield! forever !last}
let fs = (apply1thenn fs)
Seq.zip fs xs |> Seq.iter(fun (f,e) -> f e)
sa |> iter2 [(fun x -> printfn "%A" x); (fun x -> printfn "another %A" x)]
|
val sa : int list
Full name: Script.sa
val iter2 : fs:seq<('a -> unit)> -> xs:seq<'a> -> unit
Full name: Script.iter2
val fs : seq<('a -> unit)>
val xs : seq<'a>
val apply1thenn : (seq<'b> -> seq<'b>)
val fs : seq<'b>
val last : 'b ref
Multiple items
val ref : value:'T -> 'T ref
Full name: Microsoft.FSharp.Core.Operators.ref
--------------------
type 'T ref = Ref<'T>
Full name: Microsoft.FSharp.Core.ref<_>
module Unchecked
from Microsoft.FSharp.Core.Operators
val defaultof<'T> : 'T
Full name: Microsoft.FSharp.Core.Operators.Unchecked.defaultof
val unforget : (seq<'b> -> seq<'b>)
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 x : 'b
val forever : ('c -> seq<'c>)
val f : 'c
module Seq
from Microsoft.FSharp.Collections
val zip : source1:seq<'T1> -> source2:seq<'T2> -> seq<'T1 * 'T2>
Full name: Microsoft.FSharp.Collections.Seq.zip
val iter : action:('T -> unit) -> source:seq<'T> -> unit
Full name: Microsoft.FSharp.Collections.Seq.iter
val f : ('a -> unit)
val e : 'a
val x : int
val printfn : format:Printf.TextWriterFormat<'T> -> 'T
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
More information