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)