module Exercise_8 where import Foreign.Marshal.Utils import Control.Arrow import Control.Monad import Data.List import Data.Maybe import Data.Function {-WETT-} shoefa :: (Num a, Ord a) => [a] -> Int shoefa = filter toBool -- remove zeroes >>> map signum >>> zipWith subtract <*> tail -- transform to differences of signs (equals -> 0) >>> filter toBool -- keep only steps with differing signs (values /= 0) >>> length -- Insane arrow infix usage instead of . because . binds more strongly than <*>, which is no good, -- and we may as well be consistent. {-MCCOMMENT yes but what if we "on" more? shoefa' xs = length $ filter id $ on (zipWith $ on (/=) signum) ($ filter (/= 0) xs) id tail -} {-TTEW-}