Mutual recursion: Difference between revisions

(Nimrod -> Nim)
Line 1,374:
disp(ra);
disp(rb);</lang>
 
 
=={{header|Oforth}}==
 
Oforth can declare methods objects without any implementation. This allows to implement mutual excusion. This does not work with function (declaration and implementation must be together).
 
<lang Oforth>Method new: M
 
Integer method: F
{
self 0 == ifTrue: [ 1 return ]
self self 1 - F M -
}
 
Integer method: M
{
self 0 == ifTrue: [ 0 return ]
self self 1 - M F -
}
 
seqFrom(0, 20) map(#F) println
seqFrom(0, 20) map(#M) println</lang>
 
{{out}}
<pre>
>
[1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 8, 8, 9, 9, 10, 11, 11, 12, 13]
[0, 0, 1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 7, 8, 9, 9, 10, 11, 11, 12, 12]
</pre>
 
=={{header|Order}}==
1,015

edits