Motzkin numbers: Difference between revisions

→‎{{header|ALGOL 68}}: Simplify the formatting code6
(→‎{{header|ALGOL 68}}: Simplify the formatting code6)
Line 56:
# left-pads a string to at least n characters #
PROC pad left = ( STRING s, INT n )STRING:
IF INT len = ( UPB s - LWB s ) + 1; len >= n THEN s ELSE ( ( n - len ) * " " ) + s FI;
BEGIN
STRING result := s;
WHILE ( UPB result - LWB result ) + 1 < n DO " " +=: result OD;
result
END; # pad left #
 
# show the Motzkin numbers #
3,021

edits