f# - How to bind i at the end of a sequence using Seq.iteri -
mySequence |> Seq.iteri (fun ix -> ...) ...
How to Do I pack at the end of the sequence? In other words how do I represent this number of iterative iterations repeated iterations?
Of course I can make a referee and assign it to all iterations, but I wonder if there is any more elegant way?
You can use fold , so that
< Pre> Seq.iteri (funny ix -> ...)
Seq.fold (Fun ix - & Gt; ...; I + 1) 0
with these lines:
Let's do aSeq = seq {i in 1. 1.10 in printfn "Eval% d" generated i} let r = aSq | & Gt; Seq.fold (funny ix -> printfn "iter% d" x // or whatever "..." i + 1) 0 printfn "result:% d" r
< / Div>
Comments
Post a Comment