Giter Site home page Giter Site logo

fsharp.collections.immutable's Introduction

FSharp.Collections.Immutable

F# bindings for System.Collections.Immutable

.NET Core

fsharp.collections.immutable's People

Contributors

denis32000 avatar eventhelix avatar vilinski avatar xperiandri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fsharp.collections.immutable's Issues

Implement `GetSlice`

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

`skipWhile` and `takeWhile` are reversed

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.