[Haskell-beginners] Restoring interleaved lists?

Henk-Jan van Tuyl hjgtuyl at chello.nl
Fri Aug 13 05:44:10 EDT 2010


On Fri, 13 Aug 2010 03:23:13 +0200, Felipe Lessa <felipe.lessa at gmail.com>  
wrote:

>
> We have the following function in the Prelude:
>
>   splitAt :: Int -> [a] -> ([a], [a])
>
> For example,
>
>   Prelude> splitAt 3 [1..12]
>   ([1,2,3],[4,5,6,7,8,9,10,11,12])
>
> So you can write the following function (you can choose another name):
>
>   separate :: Int -> [a] -> [[a]]
>
> For example,
>
>   Prelude> separate 3 [1..12]
>   [[1,2,3],[4,5,6],[7,8,9],[10,11,12]]
>

This is the splitEvery function of package split; you can find this with  
Hayoo, using the word "split".

Regards,
Henk-Jan van Tuyl


-- 
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
--


More information about the Beginners mailing list