On recursion
- Posted by DB James <larches at comca??.net> Jul 21, 2007
- 556 views
Hi, To be sure, recursion is sometimes the way to go. I recently found myself using the pattern below several times in writing string functions (probably discovered a hundred times by Euphorians):
--====================================================================== global function StringFunc(sequence s) --basic pattern of several functions --handles 1 or many strings in s if not length(s) then return s elsif atom(s[1]) then --process single string else for i=1 to length(s) do s[i]=StringFunc(s[i]) end for end if return s end function --======================================================================
Some recursive functions are obscure, but this pattern is clear and obviously useful when processing one string or many. --Quark