## #haskell - Sat 28 Apr 2007 between 06:50 and 07:02

### NY Lost Funds

 goban http://scienceblogs.com/goodmath/2007/04/true_pathology_a_multilingual.php lambdabot Title: Good Math, Bad Math : True Pathology: A Multilingual Quine, http://tinyurl.com/23ehx8 mauke printList [] = return (); printList (hd : tl) = do putStrLn (show hd); printList tl Cale goban: yeah, that's a nice quine. :) mauke pattern matching! Cale also, putStrLn . show = print mauke then you notice that ... what Cale saidthen, mapM_ goban how the hell they come up with it Cale mauke: right :) chrizel whoo, thank you all! now it works... i'm still learning... :) Cale chrizel: printList = mapM_ print:)(mapM_ is a function in the Control.Monad library)You can probably imagine how it might be written :) _roconnor > let (*.) = "foo" in (*.) lambdabot "foo" mauke (sequence_ .) . map chrizel thanks, that works mapM_ print [1, 2, 3] mauke putStr (unlines (map show [1, 2, 3])) Cale :)mapM and mapM_ is how most loops are handled. There's also (in GHC6.6 and up) forM and forM_, which are the same thing, but with the list parameter first dolio > 23 `mod` 9 lambdabot 5 dolio @check \i -> mod (i :: Integer) 9 == (sum . map digitToInt . show \$ i) lambdabot Couldn't match expected type `Integer' against inferred type `Int' dolio @check \i -> mod (i :: Int) 9 == (sum . map digitToInt . show \$ i) lambdabot Exception: Char.digitToInt: not a digit '-' dolio @check \i -> i > 0 ==> mod (i :: Int) 9 == (sum . map digitToInt . show \$ i) lambdabot Falsifiable, after 20 tests: 9 Cale > sum . map digitToInt . show \$ 9 lambdabot 9 Cale > mod 9 9 lambdabot 0 LeCamarade @src mapM_ lambdabot mapM_ f as = sequence_ (map f as) Cale @check \i -> i > 0 ==> mod (i :: Int) 9 == mod (sum . map digitToInt . show \$ i) 9 lambdabot OK, passed 500 tests. [malte] Is there a function f, where f = flip map, predefined in any stdlib? (And how could I find out myself?) mauke @hoogle [a] -> (a -> b) -> [b]