Gah! Brain AWOL. I'm surprised no-one picked me up on
that. Why didn't I use:

splitAtMb n [] = Nothing
splitAtMb n l = Just $ splitAt n l

Actually, I've some code lying around doing exactly this (but without the padding ;)), written with the coalgebra inlined:

  split n = unfoldr $ \xs -> case xs of
    [] -> Nothing
    _  -> Just (splitAt n xs)

Cheers,

  Stefan

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to