
"Carlos J. G. Duarte"
So, what is the usefulness of that "const" function anyway? (go easy on me, I'm just beginning on this)
There are many functions in Haskell, which you wouldn't define in most other languages, including: const :: a -> b -> a flip :: (a -> b -> c) -> (b -> a -> c) id :: a -> a They become useful when used as arguments to combinators. Some examples: maybe 8 (const 16) foldl' (flip (-)) 0 id &&& length In use: maybe 8 (const 16) (Just 3) = 16 = const 16 3 maybe 8 (const 16) Nothing = 8 foldl' (flip (-)) 0 [1,2,3] = flip (-) (flip (-) (flip (-) 0 1) 2) 3 = (-) 3 ((-) 2 ((-) 1 0)) = 3 - (2 - (1 - 0)) map (id &&& length) ["abc", "de", "f"] = [("abc", 3), ("de", 2), ("f", 1)] Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad.