Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Chapter: Functions #9
Hi Alex, thank you for the great book.
in your section about mutually recursive functions, you define
which makes them always return true (for ex,
the example could be rewritten as:
but maybe it is too complex for a simple example
Grrrr. This is the second time I got this function wrong.
I want these two functions to be mutually recursive. Therefore:
A more compact solution (that is not mutually recursive) is:
It’ll be fixed in the next release of the book.
If I'm not mistaken, your proposal here above is the third time ;)
Indeed your functions don't match the definitions of even and odd numbers, as they seem to imply that all negative integers are even. But there are also negative odd numbers (-1, -3 etc).
The function definitions I proposed are mutually recursive (even calls odd, and odd calls even).
How does one read (pronounce) generic type annotations such as
"Some type a/some type b", "prime a/prime b"?
I understand the concept, I would just like to be able to speak precisely about type signatures in the context of Reason.
"One nice feature of labels is that you can mention labeled parameters in any order:"
The mathematical operation demo'd in the function (addition) does not care about operand order. I think using minus or exponent would be a little more clear.
(doing an exponent of ints is not supported by "standard" Reason I found... so probably minus is easier)