Skip to content

Commit

Permalink
Add Baklava in Verve (#3677)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzuckerm authored Dec 22, 2023
1 parent bec849c commit 4a1b565
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions archive/v/verve/baklava.vrv
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
fn abs(n: Int) -> Int {
if (n < 0) { -n } else { n }
}

let baklava_str = " *********************"

fn baklava_line(n: Int) -> String {
let num_spaces = abs(n)
let num_stars = 21 - 2 * num_spaces
substr(baklava_str, 10 - num_spaces, num_spaces + num_stars)
}

fn baklava(start: Int, end: Int) {
if not(start > end) {
print(baklava_line(start))
baklava(start + 1, end)
}
}

baklava(-10, 10)

0 comments on commit 4a1b565

Please sign in to comment.