Anonymous recursion: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added comments, added subroutine fence, added DO-END comment label, changed comments, added whitespace. -- ~~~~) |
(Added simple D entry) |
||
Line 331: | Line 331: | ||
=={{header|D}}== |
=={{header|D}}== |
||
<lang d>uint fib(in uint n) pure nothrow { |
|||
⚫ | |||
immutable self = &__traits(parent, {}); |
|||
return (n < 2) ? n : self(n - 1) + self(n - 2); |
|||
} |
|||
void main() { |
|||
import std.stdio; |
|||
writeln(fib(39)); |
|||
}</lang> |
|||
⚫ | |||
⚫ | |||
===With Anonymous Class=== |
|||
⚫ | |||
<lang d>import std.stdio; |
<lang d>import std.stdio; |
||
Line 350: | Line 362: | ||
writeln(fib(39)); |
writeln(fib(39)); |
||
}</lang> |
}</lang> |
||
The output is the same. |
|||
⚫ | |||
⚫ | |||
=={{header|Dylan}}== |
=={{header|Dylan}}== |