Baklava in M4

Published on 09 August 2025 (Updated: 09 August 2025)

Welcome to the Baklava in M4 page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

divert(-1)
dnl repeat(string, count)
define(`repeat', `ifelse(eval(($2) > 0), 1, `$1'`'`repeat($1, eval(($2) - 1))', )')
dnl indent(count, string)
define(`indent', `ifelse(eval(($1) > 0), 1, `format(`%$1s%s', `', $2)', $2)')
dnl abs(n)
define(`abs', `ifelse(eval(($1) >= 0), 1, eval($1), eval(0 - $1))')
dnl baklava(n, stop)
define(`baklava',
`ifelse(eval($1 <= $2), 1, `baklava_line($1)
baklava(eval($1 + 1), $2)', )'dnl
)
dnl baklava_line(n)
define(`baklava_line', `indent(abs($1), repeat(`*', 21 - 2 * abs($1)))')
divert(0)dnl
baklava(-10, 10)dnl

Baklava in M4 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.