F# clearly contains a lot of things that are syntactic sugar, and as I try to learn it--without the aid of a book--I am overwhelmed by the sheer variety of syntax. Is there a simpler "core" language hidden behind all that syntactic sugar? Is there a cheat sheet list of the syntactic sugars and how they map to the core language?
And hey, is there a reason F# requires a different "assignment" operator for function definitions than for lambdas, or was it a random decision? e.g. "let inc x = x+1" vs "fun x -> x+1"
A great deal of F# syntax comes from OCaml - many OCaml programs will compile and run in F# with no changes.
Good starter links:
http://msdn.microsoft.com/en-us/fsharp/default.aspx
http://en.wikibooks.org/wiki/F_Sharp_Programming
http://lorgonblog.spaces.live.com/blog/cns!701679AD17B6D310!887.entry?_c=BlogPart
Along with Brian's links, I'd like to pass along links to my own blog series, Why I Love F#, which covers some of the basics.
With regard to your second question, "let inc x = x+1" vs "fun x -> x+1" are two ways of expressing a function, but only the first one uses the assignment operator. In fact,
let inc x = x + 1
Is equivalent to:
let inc = (fun x -> x + 1)
The first is shorthand for the second, but the second might illuminate how all functions in F# are really lambdas bound to names.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With