Solving a fun little geometry problem in C# and F#
through-the-interface.typepad.com
through-the-interface.typepad.com
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