[parenscript-devel] Convenient syntax for array literals

Daniel Gackle danielgackle at gmail.com
Sat Apr 19 00:01:41 UTC 2008


Here's a neat little ps macro for easy creation of array literals, including
nested arrays:

(ps ([] 1 2 3))
=>  "[1, 2, 3];"
(ps ([] 1 (2 3)))
=>  "[1, [2, 3]];"
(ps ([] (1 2) ("a" "b")))
=>  "[[1, 2], ['a', 'b']];"
Daniel

(defpsmacro [] (&rest args)
  `(array ,@(mapcar (lambda (arg)
                      (if (and (consp arg) (not (equal '[] (car arg))))
                          (cons '[] arg)
                          arg))
                     args)))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/parenscript-devel/attachments/20080418/8ce8e853/attachment.html>


More information about the parenscript-devel mailing list