I was typing the "fun" keyword and then I remembered you don't have to in C#
Wouldn't this:
List.map (x -> x + 1) [1..10]
Be just as expressive as this?:
List.map (fun x -> x + 1) [1..10]
This makes me curious as to why the "fun" keyword is necessary at all. Can someone clarify why the "fun" keyword is syntactically required?
The language is ambiguous without it.
let x y = y z -> y z
Does x
call y
on the function z -> y z
or does it ignore its argument and return the function y z -> y z
?
Lots of decent speculative answers already... I'll add to the mix:
F# has a core language that's compatible with OCaml, and OCaml uses 'fun'.
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