Last active
October 7, 2018 15:14
-
-
Save hanachin/f021b3674d1c2f3ff326bb42ed3ef12a to your computer and use it in GitHub Desktop.
SATySFiでFizzBuzz ref: https://qiita.com/hanachin_/items/6b66e77b2b1b716b1c7b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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