Created
February 27, 2017 10:30
-
-
Save carld/169ffeff738f114a2f4cdaa62cb4ee68 to your computer and use it in GitHub Desktop.
Converting s-expressions (Lisp/Scheme) into Javascript (JSON)
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
(define (js-format l) | |
(cond | |
((null? l) "") | |
((not (list? (car l))) (string-append (format #f "'~a'" (car l)) | |
(if (not (null? (cdr l))) | |
(string-append "," (js-format (cdr l))) | |
""))) | |
(else (string-append "\n[" (js-format (car l)) | |
(if (not (null? (cdr l))) | |
(string-append "]," (js-format (cdr l))) | |
"]") )))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment