4 ms·
Solving a fun little geometry problem in C# and F#
- barrydahlberg 16y agoTook me a moment to realise the code is so weird because he's doing this in AutoCAD. My brain blocked out most of the site and went straight to the middle of the code.
- thepumpkin1979 16y agoI've read like 10 entries on that blog, that guy knows how to do some stuff.
- MichaelGG 16y agoNotice 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".