F# implementation of a takeUntil function
$ dotnet add package TakeUntiltakeUntil function Returns a collection that contains all elements of the original collection
until the given predicate returns True, and then returns no further elements.
Import TakeUntil namespace
open TakeUntil
let inputs = seq { "a"; "bb"; "ccc"; "d" }
inputs |> Seq.takeUntil (fun x -> x.Length = 3)
Evaluates to a sequence yielding the same results as
seq { "a"; "bb"; "ccc" }
let inputs = [ "a"; "bb"; "ccc"; "d" ]
inputs |> List.takeUntil (fun x -> x.Length = 3)
Evaluates to
[ "a"; "bb"; "ccc" ]
let inputs = [| "a"; "bb"; "ccc"; "d" |]
inputs |> Array.takeUntil (fun x -> x.Length = 3)
Evaluates to
[| "a"; "bb"; "ccc" |]