To understand recursion, you must understand recursion
Recursion is an integral part of functional programming. The emphasis on recursive methods in functional programming is mainly due to the reason that you don't need a mutable state, hence making it simple and straightforward to semantically define a term. Due to this prevalence of recursion as a functional construct and its semantic differences from other functional programming languages like Haskell, F# provides a keyword for recursion that is, rec
. This is how you define a recursive function:
let rec recursive-function-identifier parameter-list = recursive-function-body
Factorial is usually a simple example to begin explaining how recursion works. To jog your memory, the factorial of n is ...
Get Learning F# Functional Data Structures and Algorithms now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.