FSharp.Collections.Immutable
F# bindings for System.Collections.Immutable
This project forked from eventhelix/fsharp.collections.immutable
F# bindings for System.Collections.Immutable
License: Other
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
This test compares the behaviour between the methods for ImmutableList
and Array
#r "nuget:FSharp.Collections.Immutable"
#r "nuget:Unquote"
open FSharp.Collections.Immutable
open Swensen.Unquote.Assertions
let xs = [ "one"; "two"; "three"; "four" ]
let xsIL = ImmutableList.ofList xs
let xsA = Array.ofList xs
let notThree = (<>) "three"
test <@ (xsIL |> ImmutableList.skipWhile notThree |> ImmutableList.toArray) = (xsA |> Array.skipWhile notThree) @>
test <@ (xsIL |> ImmutableList.takeWhile notThree |> ImmutableList.toArray) = (xsA |> Array.takeWhile notThree) @>
Test failed:
xsIL |> (fun list -> ImmutableList.skipWhile notThree list) |> ImmutableList.toArray = (xsA |> (fun array -> Array.skipWhile notThree array))
seq ["one"; "two"; "three"; "four"] |> (fun list -> ImmutableList.skipWhile notThree list) |> ImmutableList.toArray = ([|"one"; "two"; "three"; "four"|] |> (fun array -> Array.skipWhile notThree array))
seq ["one"; "two"] |> ImmutableList.toArray = [|"three"; "four"|]
[|"one"; "two"|] = [|"three"; "four"|]
false
Test failed:
xsIL |> (fun list -> ImmutableList.takeWhile notThree list) |> ImmutableList.toArray = (xsA |> (fun array -> Array.takeWhile notThree array))
seq ["one"; "two"; "three"; "four"] |> (fun list -> ImmutableList.takeWhile notThree list) |> ImmutableList.toArray = ([|"one"; "two"; "three"; "four"|] |> (fun array -> Array.takeWhile notThree array))
seq ["three"; "four"] |> ImmutableList.toArray = [|"one"; "two"|]
[|"three"; "four"|] = [|"one"; "two"|]
false
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.