Hello Eugene, Thursday, January 15, 2009, 3:27:59 PM, you wrote:
but at least "length.map show" is eq to length :) > Well, your program is not equivalent to the C++ version, since it > doesn't bail on incorrect input. > 2009/1/15 Apfelmus, Heinrich <apfel...@quantentunnel.de>: >> Jonathan Cast wrote: >>> reverseDouble = >>> unlines >>> . intro >>> . map show >>> . reverse >>> . map (read :: String -> Double) >>> . takeWhile (/= "end") >>> . words >>> where >>> intro l = >>> ("read " ++ show (length l) ++ " elements") : >>> "elements in reversed order" : >>> l >> >> This can be simplified to >> >> ... . map show . reverse . map read . ... >> >> = { map f . reverse = reverse . map f } >> >> ... . reverse . map show . map read . ... >> >> = { map f . map g = map (f . g) } >> >> ... . reverse . map (show . read) . ... >> >> = { show . read = id } >> >> ... . reverse . map id . ... >> >> = { map id = id } >> >> ... . reverse . ... >> >> In other words, >> >> reverseDouble = >> unlines. intro . reverse . takeWhile (/= "end") . words >> where >> intro xs = >> ("read " ++ show (length xs) ++ " elements") : >> "elements in reversed order" : >> xs >> >> And the doubles disappeared completely. :) >> >> >> Regards, >> H. Apfelmus >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Best regards, Bulat mailto:bulat.zigans...@gmail.com _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe