arthur393

Learn Haskell

Mar 14th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - Lists
  2.  
  3. [2^n | n <- [1..10]]
  4. >[2,4,8,16,32,64,128,256,512,1024]
  5.  
  6. [n | n <- [1..10], n `mod` 2 == 0]
  7. >[2,4,6,8,10]
  8.  
  9. [c | c <- "arthur", not ( c `elem` "aeiou")]
  10. >"rthr"
  11.  
  12. - Tuples
  13.  
  14. let numbers = [1..5]
  15.  
  16. let nomes = ["arthur","batatinha","cuscuz","mama","churros"]
  17.  
  18. zip numbers nomes
  19. >[(1,"arthur"),(2,"batatinha"),(3,"cuscuz"),(4,"mama"),(5,"churros")]
  20.  
  21.  
  22. [(fst q, fst p) | q <- pairs, p <-pairs]
  23.  
  24. let pairs = zip numbers nomes
Add Comment
Please, Sign In to add comment