4 ms·
Notice how C# requires 16 type annotations, whereas F# only needed 1. The verbosity of the F# example is not necesary. For instance, the code does its own map:
by MichaelGG 16y ago
Notice how C# requires 16 type annotations, whereas F# only needed 1.
The verbosity of the F# example is not necesary. For instance, the code does its own map:
let rec fromAtoBs acc pt1 pts =
match pts with
| [] -> acc
| pt2::t ->
let ln = new Line(pt1,pt2)
fromAtoBs (ln :: acc) pt1 t
let linesFromPoint start endpts = fromAtoBs [] start endpts
Instead of just:
let linesFromPoint start endpts =
endpts |> List.map(fun x -> Line(start, x))
|> List.rev
- henning 16y agoIt's like he read the first few chapters of an F# book which showed explicit recursion for didactic purposes and then stopped before the examples explained higher-order functions.
- AndrewDucker 16y agoMost of the type definitions could have been replaced by "var".