Maybe this coding style is just too confusing?
Yes - it looks confusing,
But I think if a proper comment description is written about the recursive function (about its inputs/return, aswell note that it localises itself) then it won't be required to understand it, just use it.
Sorry I didn't include any - my point was to share the overall technique, since it looks interesting.
Note that because of all the setq's and the use of recursion the code will not be particularly fast.
Thanks for mentioning, however any recursive routine could be implemented (the one I used was just to demonstrate something practical for that technique).
Try a tail-recursive syntax.
Not sure if this is tail-recursion (but its getting more confusing) :
_$ (
from_right
)
from_left
)
)
'(1 2 3 4 5 6 7 8 9)
)
(2 3 4 5 6 7 8 9)
(2 3 4 5 6 7 8)
(3 4 5 6 7 8)
(3 4 5 6 7)
(4 5 6 7)
(4 5 6)
(5 6)
(5)
nil nil
_$ from_right
nil
_$ from_left
nil
BTW I'm a dummy at understanding recursions - just good enough to write the linear ones.
So please share your findings to build-up opinions about this.
One additional thing from me:
For that technique, the recursive function must be error-proof, since it won't be able to undefine itself when error occurs.
Should
"recursive annonymous function" be a more appropriate name?