Re: Win32Lib Update
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL> Nov 28, 1998
- 1056 views
>The function reverse() is missing from v 0.15a. >Here's my attempt at a reverse() function. Before you start a new thread, I >know this one probably isn't the fastest and doesn't reverse sequences >within sequences. >But it is useful, short and clean, IMO. Why not start a thread ? function reverse_flat (sequence s) -- Reverses only the top level sequence result result = {} for index = 1 to length(s) do result = prepend(result, s[index]) end for return result end function -- The above is the most clean and fastest, as far as I can tell. function reverse (object x) -- Reverses all levels in the sequence sequence result if atom (x) then return x end if result = {} for index = 1 to lenght(s) do result = prepend (result, reverse (s[index])) end for return result end function -- This too is the fastest (and cleanest possible). I know I can avoid one level of recursion, however Euphoria's for-statement-block-containing-only-one-statement-optimization will be missed. And for larger sequences (those who need the extra speed the most) this will make a significant difference. However, the above is all speculative, until some one starts benchmarking on this. Ralf