
Solving a fun little geometry problem in C# and F# - sudhirc
http://through-the-interface.typepad.com/through_the_interface/2010/11/solving-a-fun-little-geometry-problem-in-c-and-f.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+typepad%2Fwalmsleyk%2Fthrough_the_interface+%28Through+the+Interface%29
======
MichaelGG
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
It'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.

------
barrydahlberg
Took 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
I've read like 10 entries on that blog, that guy knows how to do some stuff.

