A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Baklava in Hobbes page! Here, you'll find the source code for this program as well as a description of how the program works.
repeatString :: (string, int) -> string
repeatString s n = if (n > 0) then s ++ repeatString(s, n - 1) else ""
iabs :: int -> int
iabs n = if (n < 0) then -n else n
baklavaLine :: int -> string
baklavaLine n =
let
numSpaces = iabs(n);
numStars = 21 - 2 * numSpaces
in
repeatString(" ", numSpaces) ++ repeatString("*", numStars)
baklava :: (int, int) -> ()
baklava n ne = if (n <= ne) then do {
putStrLn(baklavaLine(n));
baklava(n + 1, ne);
} else ()
baklava(-10, 10)
Baklava in Hobbes was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.