A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Baklava in Purescript page! Here, you'll find the source code for this program as well as a description of how the program works.
module Main where
import Prelude
import Effect (Effect)
import Effect.Console (log)
main :: Effect Unit
main = do
baklava (-10) 10
baklava :: Int -> Int -> Effect Unit
baklava n ne
| n > ne = pure unit
| otherwise = do
log (baklavaLine n)
baklava (n + 1) ne
baklavaLine :: Int -> String
baklavaLine n = do
let numSpaces = abs n
let numStars = 21 - 2 * numSpaces
(repeatString numSpaces " ") <> (repeatString numStars "*")
abs :: Int -> Int
abs n
| n < 0 = -n
| otherwise = n
repeatString :: Int -> String -> String
repeatString n s
| n < 1 = ""
| otherwise = s <> repeatString (n - 1) s
Baklava in Purescript was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.