Quiz! -Reply
- Posted by Jay Turley <jturley at MDC.COM> Oct 20, 1998
- 490 views
After running the code, I think that the following recursive reverse is more intuitively correct than the version you posted. Plus you needed an empty case to bottom out the recursion function r_reverse(sequence in) sequence out -- added this line to bottom the recursion out = {} -- for i = 1 to length(in) do if atom(in[i]) then out = in[i] & out else -- added braces to this line to 'sequencize' the recursed -- sequences -- out = r_reverse(in[i]) & out out = {r_reverse(in[i])} & out end if end for return out end function now r_reverse({"hello","world"}) will return {"dlrow","olleh"} rather than {d,l,r,o,w,o,l,l,e,h} -Jay Turley "bored at work"