Skip to content

Commit 0e81daa

Browse files
authored
Add Baklava in Idris (#4157)
1 parent 1b07781 commit 0e81daa

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

archive/i/idris/Baklava.idr

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module Main
2+
3+
repeatString : String -> Int -> String
4+
repeatString s n = if n < 1 then "" else s ++ repeatString s (n - 1)
5+
6+
baklavaLine : Int -> String
7+
baklavaLine n = repeatString " " numSpaces ++ repeatString "*" numStars
8+
where
9+
numSpaces = abs n
10+
numStars = 21 - 2 * numSpaces
11+
12+
main : IO ()
13+
main = sequence_ $ map (putStrLn . baklavaLine) [-10..10]

0 commit comments

Comments
 (0)