Guards and concatiating to lists in an anonymous function
问题 I am trying to wrap my head around the syntax of Haskell. This problem is very simple to solve logically. I have to break up a list of positive and negative integers and group them such that [1,2,3,-1,-2,-3,1,2,3] becomes [[1,2,3],[-1,-2,-3], [1,2,3]] I would like to use a higher order function, foldr to be able to do that with an anonymous function taking in two arguements. This is what I have so far. split = foldr (\ x y -> if (x > 0) then if (head (head y)) < 0 then [x] : y else x : head y