open System.IO
open System.Linq
-// For dynmic typing. To print anything in our case.
-let inline print a = printfn "%A" a
-
// Write something on a file.
let appendFile (filename: string) (text: string) =
use sw = new StreamWriter(filename, true)
yield NumCard(n, suit)
]
-// Records.
-type Person = { First: string; Last: string; Age: int }
+// Records with custom equality.
+[<CustomEquality; NoComparison>]
+type Person =
+ { First: string; Last: string; Age: int }
+ override this.Equals(other) =
+ match other with
+ | :? Person as p -> p.First = this.First && p.Last = this.Last
+ | _ -> false
+ override this.GetHashCode() =
+ this.First.GetHashCode() ^^^ this.Last.GetHashCode()
+
let steve = { First = "Steve"; Last = "Holt"; Age = 17 }
-let steves'twin = { steve with First = "Paul" }
+let stevesTwin = { steve with First = "Paul" }
// Queries. Should be used with SQL or other external data sources.
let youngPersonNames persons =