Baklava in Hobbes

Published on 01 January 2025 (Updated: 01 January 2025)

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.

Current Solution

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.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.