I wanna create a function that have the type int -> 'a list -> 'a list list
Function call:
grupper 2 [3, 1, 4, 1, 5, 9] shall return [[3, 1], [4, 1], [5, 9]]
grupper 4 [3, 1, 4, 1, 5, 9] shall return [[3, 1, 4, 1], [5, 9]]
grupper 42 [3, 1, 4, 1, 5, 9] shall return [[3, 1, 4, 1, 5, 9]].
I got this so far
fun grupper _ [] = []
| grupper n (x::xs) = if n > length(x::xs) then [x::xs]
else [List.take(x::xs, n)] @ grupper (n) xs
some help please.
You should use both
List.takeandList.drop: