On Wed, Apr 11, 2007 at 12:13:10AM +0200, Bas van Dijk wrote: > Hello, > > For my own exercise I'm writing a function 'weave' that "weaves" a > list of lists together. For example: > > weave [[1,1,1], [2,2,2], [3,3]] ==> [1,2,3,1,2,3,1,2] > weave [[1,1,1], [2,2], [3,3,3]] ==> [1,2,3,1,2,3,1] > > Note that 'weave' stops when a list is empty. Right now I have:
If it wasn't for that, you could use import Data.List(transpose) weave :: [[a]] -> [a] weave = concat . transpose e.g. > weave [[1,1,1], [2,2], [3,3,3]] ==> [1,2,3,1,2,3,1,3] Brandon _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
