open System.Linq
let repeat x = Seq.initInfinite (fun _ -> x)
let scan = Seq.scan
let iterate f x = scan (fun l _ -> f l) x (repeat x)
let any = Enumerable.Any
let take n = fun xs -> Enumerable.Take (xs, n)
let skip n = fun xs -> Enumerable.Skip (xs, n)
let unfold h p t = iterate t >> Seq.takeWhile p >> Seq.map h
let splitAt n = unfold (take n) any (skip n)
No comments:
Post a Comment