3 ms·
In Forth language would be: : fib 2dup + ; 2dup word duplicates n and n-1 elements and put it on the top of the stack. + word takes n and n-1 elements from
by emersonrsantos 8y ago
In Forth language would be:
: fib 2dup + ;
2dup word duplicates n and n-1 elements and put it on the top of the stack.
+ word takes n and n-1 elements from the stack and sum them. The result goes on top of the stack.
Just start with 1 and 1 at the top of stack.
- willvk 8y agoThat's some very concise code golf! It would be interesting in seeing how Forth compiles this under the hood.
- pjc50 8y agoNormally Forth is interpreted. Compiled Forth code is unlikely to look particularly clean or elegant. (If you like languages with a very high density of functionality to symbol count, you should look at APL and its successor J)