@urusan The SML-NJ programming language uses pattern matching to select on what variant of a function runs based on the input arguments. It is idiomatic to define functions recursively, such as the factorial function, which yields 1 if you try to take factorial of 0 (0!) or x * fact(x-1) if you try to take a number larger than 0.

This results in the definition of a factorial function in SML-NJ usually starting with

`fun fact 0 = 1`

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.