Question
How to iterate over ReadOnlySpan in F#?
You can get Spans via System.Memory to.NET Standard 2.0 compatible libraries.
But how do you do this the most efficiently in F#:
let myRsp = "test1".AsSpan()
let test = Seq.forall (fun x -> Char.IsLower x) myRsp
ReadOnlySpan<char>
seems not to be compatible with Seq/Array/List and doing .ToArray() is making a copy. And if you try something like seq { for c in myRsp do yield (Char.IsLower c) } |> Seq.forall id
you cannot do it because seq { }
is like a function and you cannot transfer ReadOnlySpan<char>
easily between functions.