Skip to content

Commit cb388f7

Browse files
authored
Add Baklava in Ferret (#4194)
1 parent 8291f49 commit cb388f7

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

archive/f/ferret/baklava.clj

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
(defn print-repeat-string
2+
([s n]
3+
(if (> n 0)
4+
(do
5+
(print s)
6+
(print-repeat-string s (dec n))
7+
)
8+
)
9+
)
10+
)
11+
12+
(defn baklava-line
13+
([n]
14+
(let [
15+
num-spaces (abs n)
16+
num-stars (- 21 (* 2 num-spaces))
17+
]
18+
(print-repeat-string " " num-spaces)
19+
(print-repeat-string "*" num-stars)
20+
(println)
21+
)
22+
)
23+
)
24+
25+
(defn baklava
26+
([n ne]
27+
(if (<= n ne)
28+
(do
29+
(baklava-line n)
30+
(baklava (inc n) ne)
31+
)
32+
)
33+
)
34+
)
35+
36+
(do
37+
(baklava -10 10)
38+
)

0 commit comments

Comments
 (0)