Advertisement
Rementai

choinki haskell

May 25th, 2023
1,131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. printSpaces :: Int -> IO ()
  2. printSpaces n = putStr (replicate n ' ')
  3.  
  4. printStars :: Int -> IO ()
  5. printStars n = putStrLn (replicate n '*')
  6.  
  7. printMirrorUpperStarTriangle :: Int -> Int -> IO ()
  8. printMirrorUpperStarTriangle n x
  9.     | x > n = return ()
  10.     | otherwise = do
  11.         printSpaces (n - x)
  12.         printStars (2 * x - 1)
  13.         printMirrorUpperStarTriangle n (x + 1)
  14.  
  15. main :: IO ()
  16. main = do
  17.     putStrLn "wprowadz wysokosc: "
  18.     input <- getLine
  19.     let height = read input :: Int
  20.     printMirrorUpperStarTriangle height 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement