Reputation: 41909
How can I convert a list of lists [[a]]
into a tuple ([a], [a])
?
Example:
input: [[1], [2,3,4]]
output: ([1], [2,3,4])
Upvotes: 0
Views: 503
Reputation: 53871
How about pattern matching?
convert :: [[a]] -> Maybe ([a], [a])
convert [x, y] = Just (x, y)
convert _ = Nothing
The Maybe
is just to handle the case where we don't have exactly two elements in our list.
Upvotes: 9