Advertisement
Arina0904

Haskell DO

Oct 26th, 2022 (edited)
1,129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. main = do
  2. --     putStrLn("Enter the name:")
  3. --     x<-getLine
  4. --     putStrLn("Hello, " ++ x)
  5. --     putStrLn("How are u?")
  6.  
  7. --     putStrLn("Enter the x:")
  8. --     x<-readLn
  9. --     putStrLn("Enter the y:")
  10. --     y<-readLn
  11. --     putStrLn("Summa = " ++ show (y+x))
  12. --    или return(y+x)
  13.  
  14.     putStrLn("Spisok: ")
  15.     x<-getLine
  16.     putStrLn(show x)
  17.     putStrLn(show(words x))
  18.     let y = map (\l -> read l :: Int) (words x)
  19.     putStrLn(show y)
  20.     let z = last y
  21.     putStr("Last element: ")
  22.     return (z)
  23.  
  24.  
  25.  
  26.   x1<-readFile "in"
  27.         let x2 = init x1
  28.         let y = map (\l -> read l :: Int) (words x2)
  29.         let z = last$init y
  30.         writeFile "out" "PreLast element:\n"
  31.         appendFile "out" (show z)
  32.         return (x2)    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement