Skip to content

Commit f64d31a

Browse files
authored
Add Baklava in Koka (#4151)
1 parent ddcea9d commit f64d31a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

archive/k/koka/baklava.kk

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
fun repeat_string(s : string, n : int) {
2+
var result := ""
3+
list(1, n).foreach(fn(_) { result := result + s })
4+
result
5+
}
6+
7+
fun main() {
8+
list(-10, 10).foreach(fn(n) {
9+
var num_spaces := abs(n)
10+
var num_stars := 21 - 2 * num_spaces
11+
println(repeat_string(" ", num_spaces) + repeat_string("*", num_stars))
12+
})
13+
}

0 commit comments

Comments
 (0)