Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- getInt function
  2. -- Reads a line from standard in and transforms it to integer.
  3. getInt :: IO Int
  4. getInt = do
  5.             line <- getLine
  6.             return (read line :: Int)
  7.  
  8. -- sI function
  9. -- Takes an integer as parameter, reads another integer, and sums the two.
  10. -- Continues until 0 is input.
  11. sI:: Int -> IO Int
  12. sI s = do
  13.         n<-getInt
  14.         if n==0
  15.             then return s
  16.         else sI (s+n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement