Skip to content

Instantly share code, notes, and snippets.

@mmontone
Created March 4, 2019 16:09
Show Gist options
  • Save mmontone/f5dbbfa9928832f75ca40e411ff4c680 to your computer and use it in GitHub Desktop.
Save mmontone/f5dbbfa9928832f75ca40e411ff4c680 to your computer and use it in GitHub Desktop.
Tile like code generation with fmt
;; 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