Skip to content

Commit

Permalink
Add Baklava in Gluon
Browse files Browse the repository at this point in the history
  • Loading branch information
rzuckerm committed Dec 31, 2024
1 parent bb7836e commit 990c848
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions archive/g/gluon/baklava.glu
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
let io @ { ? } = import! std.io
let int @ { ? } = import! std.int

rec let repeat_string s n : String -> Int -> String =
if n > 0 then
s ++ (repeat_string s (n - 1))
else
""

let baklava_line n : Int -> String =
let num_spaces = int.abs n
let num_stars = 21 - 2 * num_spaces
(repeat_string " " num_spaces) ++ (repeat_string "*" num_stars)

rec let baklava n ne : Int -> Int -> io.IO () =
if n <= ne then
io.println (baklava_line n)
baklava (n + 1) ne
else
io.print ""

baklava -10 10

0 comments on commit 990c848

Please sign in to comment.