Anonymous recursion: Difference between revisions

Content added Content deleted
m (→‎{{header|Quackery}}: improved text)
Line 2,338: Line 2,338:
This limitation can be overcome with the understanding that recursion can be factored out into two ideas, i.e. self-reference and evaluation. The self-reference word in Quackery is <code>this</code>, which puts a pointer to the current nest on the data stack (usually just called "the stack") and the evaluation word is <code>do</code>, which takes an item from the stack and evaluates it. So <code>this do</code> is equivalent to <code>recurse</code>.
This limitation can be overcome with the understanding that recursion can be factored out into two ideas, i.e. self-reference and evaluation. The self-reference word in Quackery is <code>this</code>, which puts a pointer to the current nest on the data stack (usually just called "the stack") and the evaluation word is <code>do</code>, which takes an item from the stack and evaluates it. So <code>this do</code> is equivalent to <code>recurse</code>.


The final example fixes the previous example by using <code>this</code> and <code>do</code> to put the pointer to the current nest on the stack at the correct level of nesting and evaluate it within the nested nests.
The final example fixes the previous example by using <code>this</code> and <code>do</code> to put the pointer to the current nest on the stack at the correct level of nesting and evaluate it within the nested nests. See also [http://rosettacode.org/wiki/Even_or_odd#Quackery:_With_Anonymous_Mutual_Recursion Even or Odd#Quackery: With Anonymous Mutual recursion].


<pre>[ dup 0 < iff
<pre>[ dup 0 < iff