5 ms·
Corecursion doesn't mean what you think it means. You mean mutual recursion.
by DanWaterworth 12y ago
Corecursion doesn't mean what you think it means. You mean mutual recursion.
- waterhouse 12y ago(read this with a mild trollface) Given functions f and g, it is possible to write them as the same function M. Supply an extra argument called "mode": if 0, then the function behaves like f, and if 1, then the function behaves like g. If you want to call f or g, call M with the "mode" argument as 0 or 1 respectively. If f and g take different numbers of arguments, let M take the larger number of arguments, and when you intend to call the function that takes fewer arguments, supply 0s for the extra args. This should indeed implement mutual recursion in terms of self-recursion. The grandparent commenter did say "Corecursion could (if awkwardly) be converted into ordinary recursion", which I would say is technically correct, which some say is the best kind of correct. (Perhaps he has a somewhat less awkward scheme in mind.)
- dllthomas 12y agoYou seem to be talking about mutual recursion. http://en.wikipedia.org/wiki/Corecursion http://en.wikipedia.org/wiki/Corecursion http://en.wikipedia.org/wiki/Mutual_recursion http://en.wikipedia.org/wiki/Mutual_recursion
- dllthomas 12y agoIt occurs to me that the existence (and nature) of "coroutines" probably primes this mistake.