Walk through a list split function in Haskell
问题 This is a follow up to my previous question. I am trying to understand the list splitting example in Haskell from here: foldr (\a ~(x,y) -> (a:y,x)) ([],[]) I can read Haskell and know what foldr is but don't understand this code. Could you walk me through this code and explain it in more details ? 回答1: Let’s try running this function on a sample input list, say [1,2,3,4,5] : We start with foldr (\a ~(x,y) -> (a:y,x)) ([],[]) [1,2,3,4,5] . Here a is the first element of the list, and (x,y)