I'm new to Haskell and currently trying to understand pattern matching. So would it be possible to get the last 3 elements from a list like this one:
[[1,2,3,4,5,6], [5,6,7,8,9], [10,11,12,13]] to return something like this [(4,5,6), (7,8,9), (11,12,13)]?
here's my code
lastElems [] = []
lastElems ((x:xs):ys) = drop (length xs - 3) xs : lastElems ys
I think it does what it supposed to do but it returns as lists in a list instead of tuples. Could anyone please give me a hint on how to tackle this?
And does this also mean that you can't use (:) with tuples? Thanks in advance.