FSharp.Collections.Immutable icon indicating copy to clipboard operation
FSharp.Collections.Immutable copied to clipboard

Implement `GetSlice`

Open xperiandri opened this issue 2 years ago • 0 comments

Like

[<Extension>]
type SliceExtensions =

    [<Extension>]
    static member GetSlice(source: FlatList<'t>, from: int option, ``to``: int option) =
        let from = from |> Option.defaultValue 0
        let ``to`` = ``to`` |> Option.defaultValue source.Length
        source
        |> Seq.skip from
        |> Seq.take (``to`` - from + 1)
        |> Seq.toFlatList

xperiandri avatar Sep 14 '23 22:09 xperiandri