I want to split a list on 1 element and take the rest of the list in the second of the tuple and return that.
like this: *> split [1,2,3,2] gives [(1,[2,3,2]),(2,[1,3,2]),(3,[1,2,2]),(2,[1,2,3])]
I tried some code like this but it keeps giving me errors. Can someone help me out with this?
split :: [Int] -> [(Int,[Int])]
split [] = []
split (x:xs) = (map (x:) (map snd (split xs))) ++ [(x,[])]
Thx!
(x:)onto[(Int, [Int])], since(Int, [Int])is not a list. 3. If you only usexsin the recursive call, you would always forget the start of the list. 4. Try to be more verbose. Write a function that, for a given index, splits the indexed value and the rest. Use this together withzipWith [0..]for a first prototype.