Skip to content

Commit

Permalink
Add Baklava in Modula2 (#4126)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzuckerm authored Dec 24, 2024
1 parent 662ff1e commit 71346ac
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions archive/m/modula2/Baklava.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
MODULE Baklava;

FROM StrIO IMPORT WriteString, WriteLn;

PROCEDURE WriteRepeatString(s: ARRAY OF CHAR; n: CARDINAL);
VAR i: CARDINAL;
BEGIN
FOR i := 1 TO n DO
WriteString(s);
END
END WriteRepeatString;

VAR
n: INTEGER;
numSpaces: CARDINAL;
numStars: CARDINAL;

BEGIN
FOR n := -10 TO 10 DO
numSpaces := ABS(n);
numStars := 21 - 2 * numSpaces;
WriteRepeatString(' ', numSpaces);
WriteRepeatString('*', numStars);
WriteLn;
END;
END Baklava.

0 comments on commit 71346ac

Please sign in to comment.