Created
March 4, 2019 16:09
-
-
Save mmontone/f5dbbfa9928832f75ca40e411ff4c680 to your computer and use it in GitHub Desktop.
Tile like code generation with fmt
This file contains hidden or 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
;; http://250bpm.com/blog:149 | |
(ql:quickload :fmt) | |
(ql:quickload :access) | |
(defparameter *data* | |
'(("Afghanistan" . "Kabul") | |
("Brazil" . "Brasilia") | |
("Canada" . "Ottawa"))) | |
(let* ((body (fmt:with-fmt () | |
(:do (item *data*) | |
"printf(\"" (car item) " is the capital of " (cdr item) "\");" #\newline))) | |
(program (fmt:with-fmt () | |
"#include <stdio.h>" #\newline #\newline | |
"int main(void) {" #\newline | |
body | |
"return 0;"))) | |
program) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment