On Thu, Feb 28, 2008 at 4:28 AM, Aaron Altman <[EMAIL PROTECTED]> wrote: > runActionAndIterate :: [a -> a] -> a -> (a, [a -> a]) > runActionAndIterate (currentAction:actionList) actionInput = > (currentAction actionInput, concat [actionList, [currentAction]]) > > shiftActionList :: [a -> a] -> [a -> a] > shiftActionList (currentHead:rest) = concat [rest, [currentHead]]
As a side note, it's not good to recreate the list (using 'concat') for every item as it is an O(n) operation. Bas van Dijk's 'always' (also called 'forever'[1]) is an option, but you can also create a circular list using the simple function 'cycle'[2] and your functions above would become runActionAndIterate (currentAction:actionList) actionInput = (currentAction actionInput, actionList) shiftActionList = tail [1] http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Monad.html#v%3Aforever [2] http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v%3Acycle -- Felipe. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe