Re: Discuss changing the behaviour of append()
- Posted by petelomax Jun 21, 2014
- 4099 views
_tom said...
Here is some code to test append:
FYI (this does not really add anything to the subject being discussed), this is how I would code that (if I had to use recursion):
sequence s = {1,2,3,4,5,6,7,8,9,10} function isEven(atom x) --common utility function return remainder( x,2 ) = 0 end function function extractEvens(sequence source, integer done=0, sequence thusfar={}) done += 1 if done>length(source) then return thusfar end if atom thisone = source[done] if isEven(thisone) then thusfar = append(thusfar,thisone) end if return extractEvens(source, done, thusfar) end function ? extractEvens(s)

