Skip to content

Commit bc2d0df

Browse files
authored
Add Baklava in Chaiscript (#4254)
1 parent d1dcdc2 commit bc2d0df

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

archive/c/chaiscript/baklava.chai

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def repeat_string(s, n) {
2+
var result = "";
3+
for (var i = 0; i < n; ++i) {
4+
result += s;
5+
}
6+
7+
return result;
8+
}
9+
10+
for (var n = -10; n <= 10; ++n) {
11+
var num_spaces = (n < 0) ? -n : n;
12+
var num_stars = 21 - 2 * num_spaces;
13+
print(repeat_string(" ", num_spaces) + repeat_string("*", num_stars));
14+
}

0 commit comments

Comments
 (0)