Skip to content

Commit ddcea9d

Browse files
authored
Add Baklava in Kitten (#4149)
1 parent 1cd6182 commit ddcea9d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

archive/k/kitten/baklava.ktn

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
define repeat_string (List<Char>, Int32 -> List<Char>):
2+
-> s, n;
3+
if (n > 0) {
4+
s s n 1 (-) repeat_string (+)
5+
} else {
6+
""
7+
}
8+
9+
define baklava_line (Int32 -> List<Char>):
10+
-> n;
11+
n abs -> num_spaces;
12+
21 2 num_spaces (*) (-) -> num_stars;
13+
" " num_spaces repeat_string
14+
"*" num_stars repeat_string (+)
15+
16+
define baklava (Int32, Int32 -> +IO):
17+
-> n, ne;
18+
if (n <= ne) {
19+
n baklava_line say
20+
n 1 (+) ne baklava
21+
}
22+
23+
-10 10 baklava

0 commit comments

Comments
 (0)