Skip to content

Instantly share code, notes, and snippets.

@hanachin
Last active October 7, 2018 15:14
Show Gist options
  • Save hanachin/f021b3674d1c2f3ff326bb42ed3ef12a to your computer and use it in GitHub Desktop.
Save hanachin/f021b3674d1c2f3ff326bb42ed3ef12a to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
let-inline ctx \fizzbuzz m = script-guard Latin (embed-math ctx m) in
let ctx = get-initial-context 440pt (command \fizzbuzz) in
let fizzbuzz-str n =
match ((n mod 3), (n mod 5)) with
| (0, 0) -> `FizzBuzz`
| (0, _) -> `Fizz`
| (_, 0) -> `Buzz`
| _ -> arabic n
in
let fizzbuzz-line n = line-break true true ctx (read-inline ctx (embed-string (fizzbuzz-str n))) in
let fizzbuzz n upto =
let-rec iter i acc =
if i == upto then
acc +++ fizzbuzz-line i
else
iter (i + 1) (acc +++ (fizzbuzz-line i))
in
iter 1 block-nil
in
page-break
A4Paper
(fun pbinfo -> (|
text-height = 842pt;
text-origin = (0pt, 0pt);
|))
(fun (pbinfo) -> (|
header-content = block-nil;
header-origin = (0pt, 0pt);
footer-content = block-nil;
footer-origin = (0pt, 0pt);
|))
(fizzbuzz 1 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment