I am new to Haskell, while working on small programs I found little confusions about functioning of lambda functions.
lastThat :: (a -> Bool) -> a -> [a] -> a
lastThat f = foldl (\x acc -> if f x then x else acc)
Executing lastThat (>0) 100 [-1,-4,5,7,9,-10]
I got 100 . While using the following definition
lastThat :: (a -> Bool) -> a -> [a] -> a
lastThat f = foldl (\acc x -> if f x then x else acc)
& then executing lastThat (>0) 100 [-1,-4,5,7,9,-10]
I got 9 as expected.
Why it did not worked with first definition?