Factorial recursion error
Hey! Thanks for the bug report. I'll take a look tonight and get back to you.
I got the definition of primrec all wrong, so this example from the original Joy doesn't work at all.
Remove the wrong definition, rename the thing I have (i genrec), and (maybe) implement the OG primrec combinator.
Okay, from the URL above, the primrec operator is described like so:
http://www.kevinalbrecht.com/code/joy-mirror/j00ovr.html
In Joy there is a combinator for primitive recursion which has this pattern built in and thus avoids the need for a definition. The primrec combinator expects two quoted programs in addition to a data parameter. For an integer data parameter it works like this: If the data parameter is zero, then the first quotation has to produce the value to be returned. If the data parameter is positive then the second has to combine the data parameter with the result of applying the function to its predecessor.
So like this I think: ... I made some ASCII art Gentzen diagrams but the tickets system thinks they are spam. :(
Anyhow, the thing to do is pick a different name for i genrec like tail-recur or just tailrec, and maybe implement a primrec combinator.
But the description makes it sound polymorphic, and I'm not at all sure I want that.
It can also be used with data types other than integers.
https://osdn.net/projects/joypy/scm/hg/Joypy/commits/32029eabc1e8204d727aff2976837ce6d29c7ba4
Rename primrec to tailrec.
This is most of it done. I'm going to close the ticket and worry about implementing primrec later.
I am following along with http://www.kevinalbrecht.com/code/joy-mirror/j00ovr.html the tutorial.
I am trying to calculate the recursive factorial of a number, however I encounter the following error.
joy? 5 1 * primrec
[5 [1 * i genrec] i] 1 [] 5 . infra first choice i
Traceback (most recent call last):
TypeError: 'int' object has no attribute 'getitem' What differences are there in Thun to the Joy described in that tutorial, and does there exist some documentation of the differences?