Advertisement
Manioc

get list

Oct 5th, 2018
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. ref::String->Int
  4. ref tipo | tipo == "cafe" = 8
  5.          | tipo == "almoco" = 12
  6.          | tipo == "jantar" = 10
  7.  
  8. tot::[String]->Int
  9. tot [] = 0
  10. tot (f:r) = (ref f) + (tot r)
  11.  
  12.  
  13. getList::Int->[IO String]
  14. getList 0 = []
  15. getList n = [a | a<-[getNumber] ] ++ getList(n-)
  16.  
  17. getNumber::IO String
  18. getNumber = do
  19.     s <- getLine
  20.     return s
  21.  
  22. main::IO()
  23. main = do
  24.     n <- getLine
  25.     arr <- sequence(getList (read n))
  26.     print (tot arr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement