Skip to content

Commit

Permalink
Add Baklava in Gluon (#4168)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzuckerm authored Jan 1, 2025
1 parent 35553f3 commit 336432a
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 336432a

Please sign in to comment.