Built-in/more elegant version of this function?

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)

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]] [[1,3],[2,4],[5]] could be more or less what you want.
participants (2)
-
Daniel Fischer
-
Jordan Cooper