Created
August 18, 2017 07:34
-
-
Save Szer/f580686fdf8b10afbc8a21496480de2d to your computer and use it in GitHub Desktop.
example of immutable list in F#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let a = new obj(); | |
let b = new obj(); | |
let c = new obj(); | |
a.Equals(b) // <- false | |
b.Equals(c) // <- false | |
c.Equals(a) // <- false | |
let aList = [a] // <- [System.Object] | |
let bList = [b] // <- [System.Object] | |
let cList = [c] // <- [System.Object] | |
let abList = aList @ bList // <- [System.Object; System.Object] | |
abList.Head.Equals(a) // <- true | |
abList.Tail.Head.Equals(b) // <- true | |
let abcList = abList @ cList // <- [System.Object; System.Object; System.Object] | |
abcList.Head.Equals(a) // <- true | |
abcList.Tail.Head.Equals(b) // <- true | |
abcList.Tail.Tail.Head.Equals(c) // <- true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment