What is + in F #?

Why can't I do something like

let sum = List.fold + 0 aListOfNumbers
+3
source share
1 answer

Because if you write it this way, F # thinks you're trying to call +with List.foldas its left argument and 0 aListOfNumbersas its right argument.

To give an infix operator as an argument to the function you need to copy into it:

let sum = List.fold (+) 0 aListOfNumbers
+14
source

All Articles