
13 Aug
2010
13 Aug
'10
5:44 a.m.
On Fri, 13 Aug 2010 03:23:13 +0200, Felipe Lessa
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 --