I'm working through a textbook on F# and after introducing the factorial function
let rec fact = function | 0 -> 1 | n-> n * fact(n-1);;
the authors also point out that the evaluation of an expression containing fact
might not terminate and add in a footnote
Note that a text like
fact
n is not part of F#. It is a schema where one can obtain a program piece by replacing the meta symbol n with a suitable F# entity.
This has gone right over my head! Although I'm happy with how fact
works, and with recursion in other languages, I can't see the distinction the authors are trying to make here. Any explanations welcome.
I suspect all they're trying to say is n
represents a value (i.e., "F# entity") being passed to the function. fact n
is not meant to be valid F# code.
It's legalese for "n
is a placeholder."
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