TW 5.3.0 introduced functions and they can be used in a recursive manner. I tried to implement the Fibonacci sequence (already impletemted in TW by @Mark_S. See TW-Scripts) using functions as below
But I failed, using large number like 10 makes Tiddlywiki unresponsive!
EDITED
The problem solved. See below solution. The issue was with :map. It processes all comming input from previous filter runs. I had to use :map in .step only one time.
The code is correct (I assume ) It uses below formula
F(0) = 0 F(1) = 1
For n> 1
I think the way recursive function works is the problem or my understanding of recursive function is not correct! ( I assume the latter) F(n) = F(n-1) + F(n-2)
To me recursion is when something calls itself. When it does so with a filter it will call itself N times according to that filter, then each time it is called it will again call itself N times if there are items to be recursed.
The TOC is the default examples, recursion typically runs out a full tree.
Recursions can become eternal loops if there is an internal self reference, or a logical error that stops each level of the recursion stopping.
I could only get 3 in your example, and some odd behaviour. If it iterates until it finds the fibonaci number it is kind of recursive, but to me its more of an iteration.
This is the working version. I modified the original post. The math behind this solution is fibo(n) = fibo(n-1) + fibo(n-2). You can make your function global (put in a tiddler tagged with $:/tags/Macro) to get access to them in any tiddler you like.
NOTE: The above solution runs the function for every number is given like <<.fibo n>>. A better solution is to keep intermediate numbers and generate the sequence from f(0) to f(n)
Thanks @Mohammad and @jeremyruston with these helpful examples with the new functions. I have added to my library.
I am still learning
Of course as we and the community start to get familiar, I try to predict how best to code, to increase readability and understanding. In this case I would think for occasional use it may be better not to use abbreviations like fibo but use the full Fibonacci but then also realised we can also define a macro;