Skip to content

Commit ff6db14

Browse files
authored
Add Baklava in OCaml (#4107)
1 parent 2b85e5a commit ff6db14

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

archive/o/ocaml/baklava.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(** https://rosettacode.org/wiki/Repeat_a_string#OCaml **)
2+
let string_repeat n s =
3+
String.concat "" (Array.to_list (Array.make n s));;
4+
5+
for n = -10 to 10 do
6+
let num_spaces = abs n in
7+
let num_stars = 21 - 2 * num_spaces in
8+
Printf.printf "%s%s\n" (string_repeat num_spaces " ") (string_repeat num_stars "*");
9+
done

0 commit comments

Comments
 (0)