fork download
  1. zipper x y = (sqrt x + sqrt y, x, y)
  2.  
  3. predicateA (z,_,_) = z > 9 && z < 99
  4. a = filter predicateA [ zipper x y | x <- [1..], y <- [1..] ]
  5.  
  6. predicateBDrop (z,_,_) = z <= 9
  7. predicateBTake (z,_,_) = z < 99
  8. limit = (takeWhile predicateBTake) . (dropWhile predicateBDrop)
  9. calcZ ys x = limit $ map (zipper x) ys
  10. b = concat $ takeWhile (not . null) $ map (calcZ [1..]) [1..]
  11.  
  12. last2 [] = []
  13. last2 [x] = [x]
  14. last2 [x, y] = [x,y]
  15. last2 (x:xs) = last2 xs
  16.  
  17. run xs = do
  18. mapM_ print $ take 2 xs
  19. putStrLn ".."
  20. mapM_ print $ last2 xs
  21. putStrLn $ "total items count: " ++ show (length xs)
  22.  
  23. main = run b
  24.  
  25.  
Success #stdin #stdout 2.6s 1298244KB
stdin
Standard input is empty
stdout
(9.06225774829855,1.0,65.0)
(9.12403840463596,1.0,66.0)
..
(98.98979538707079,9602.0,1.0)
(98.99489782636645,9603.0,1.0)
total items count: 15999176