[Haskell-beginners] Built-in/more elegant version of this function?

Daniel Fischer daniel.is.fischer at web.de
Mon Oct 26 14:59:32 EDT 2009

Am Montag 26 Oktober 2009 18:49:51 schrieb Jordan Cooper:
> I was wondering if there is a built-in way to do what this function I
> wrote does (or at least a more elegant way, preferably without
> explicit recursion).
> f xss = map safeHead xss : f (map safeTail xss)
> (where safeHead/Tail are versions of head/tail that don't crash on []
> input) 

Not quite the same, but

Prelude> :m +Data.List
Prelude Data.List> transpose [[1,2],[],[3,4,5]]

could be more or less what you want.

More information about the Beginners mailing list