fork download
  1. import Prelude hiding (drop, dropWhile)
  2.  
  3. drop n xs = foldl tailor xs [1..n]
  4.  
  5. dropWhile f xs = foldl tailor xs $ truths f xs
  6.  
  7. tailor [] _ = []
  8. tailor xs _ = tail xs
  9.  
  10. truths f [] = []
  11. truths f (x:xs) = if f x then True : truths f xs else []
  12.  
  13. main = do
  14. let xs = [1..10]
  15. let pd n = print $ drop n xs
  16. let pw f = print $ dropWhile f xs
  17. pd (-1)
  18. pd 0
  19. pd 1
  20. pd 20
  21. pw (< 0)
  22. pw (< 5)
  23. pw (< 15)
  24.  
Success #stdin #stdout 0s 4704KB
stdin
Standard input is empty
stdout
[1,2,3,4,5,6,7,8,9,10]
[1,2,3,4,5,6,7,8,9,10]
[2,3,4,5,6,7,8,9,10]
[]
[1,2,3,4,5,6,7,8,9,10]
[5,6,7,8,9,10]
[]