[Haskell-beginners] Partition a list recursively
alexandre+haskell at delanoe.org
Tue Nov 3 10:12:31 UTC 2015
I am looking for such function:
function :: Ord a => [a] -> [a] -> [[a]]
function [1,3,6] [0..6] == [[0,1],[2,3],[4,5,6]]
Question: does it exist already ? If no, continue:
partIt :: Ord a => a -> [a] -> [[a]]
partIt m xs = [takeWhile (<= m) xs, dropWhile (<= m) xs]
partIt 1 [0..5] == [[0,1],[2,3,4,5]]
Question: How to define recursively partIt
1) with a list as parameter ?
2) recursively on the second part of the list ?
Thanks for help,
More information about the Beginners