1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-20 01:57:09 +03:00
mal/pil/printer.l
Vasilij Schneidermann a870ad3f5e Implement step 1
2016-10-02 15:55:19 +02:00

17 lines
689 B
Plaintext

(de pr-str (Ast PrintReadably)
(let Value (get Ast 'value)
(case (get Ast 'type)
((true false nil)
(sym @) )
(string (if PrintReadably (if Value (sym Value) "\"\"") Value))
(keyword (pack ":" Value))
((number symbol) Value)
(list (pr-list Value PrintReadably "(" ")"))
(vector (pr-list Value PrintReadably "[" "]"))
(map (pr-list Value PrintReadably "{" "}"))
(T (throw 'err (new '(+MALError) "[pr-str] unimplemented type"))) ) ) )
(de pr-list (Forms PrintReadably Starter Ender)
(let Values (mapcar '((Form) (pr-str Form PrintReadably)) Forms)
(pack Starter (glue " " Values) Ender) ) )