Advertisement
Guest User

Deforestation1

a guest
Jan 25th, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Data.Char
  2. import Data.List
  3.  
  4. func = foldr (+) 0 . map (\x -> x * 10)
  5.  
  6. func' xs = foldr (+) 0 $ map (\x -> x * 10) xs
  7.  
  8. func'' xs = case map (\x -> x * 10) xs of
  9.                                       [] -> 0
  10.                                       x:xs -> x + foldr (+) 0 xs
  11. func''' xs = case (case xs of
  12.                            [] -> []
  13.                            x:xs -> (\x -> x * 10) x : map (\x -> x * 10) xs) of
  14.                                                                              [] -> 0
  15.                                                                              x:xs -> x + foldr (+) 0 xs
  16. func'''' xs = case xs of
  17.                       [] -> case [] of
  18.                                     [] -> 0
  19.                                     x:xs -> x + foldr (+) 0 xs
  20.                       x:xs -> case (\x -> x * 10) x : map (\x -> x * 10) xs of
  21.                                                                             [] -> 0
  22.                                                                             x:xs -> x + foldr (+) 0 xs
  23.  
  24. func''''' xs = case xs of
  25.                       [] -> 0
  26.                       x:xs -> (\x -> x * 10) x + foldr (+) 0 (map (\x -> x * 10) xs)
  27.  
  28. answer xs = case xs of
  29.                    [] -> 0
  30.                    x:xs -> (\x -> x * 10) x + answer xs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement