[Haskell-cafe] Re: split string into n parts
Stefan Holdermans
stefan at cs.uu.nl
Tue Oct 24 08:04:54 EDT 2006
> 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
More information about the Haskell-Cafe
mailing list