arrays - What is the most idiomatic style to force a computation using Sequences in f#? -
i have side-effective operation
securities |> seq.map (fun x -> request.append("securities",x))
what idiomatic way have code perform ?
i wrote seq.doit, itches
module seq = let doit sa = sa |> seq.toarray |> ignore
deferred sequences used when create sequences using seq.delay
or sequence expression seq{}. function on sequence returning datatype other seq
can force computation.
alternatively, can use for
loop instead of seq.iter
:
for s in securities request.append("securities", s)
if want hide side effects , return request
later use, seq.fold
choice:
securities |> seq.fold (fun acc x -> acc.append("securities", x); acc) request
Comments
Post a Comment