3 ms·
Why not [1 2 3] and {foo 3 bar 4}? Clojure gets it right. :)
by piranha 14y ago
Why not [1 2 3] and {foo 3 bar 4}? Clojure gets it right. :)
- ynniv 14y agoTwo of the best parts of clojure (over other lisps).
- Xurinos 14y agoFor Common Lisp to support converting [1 2 3] to a vector: ; [] to #() (defun bracket-reader (stream char) (declare (ignore char)) `(vector ,@(read-delimited-list #\] stream t))) (set-macro-character #\[ #'bracket-reader) (set-syntax-from-char #\] #\)) And for your in-place hash: ; {} to hash (defun set-hash-values (hash pairs) (when pairs (setf (gethash (car pairs) hash) (cadr pairs)) (set-hash-values hash (cddr pairs)))) (defun in-place-hash (stream char) (declare (ignore char)) `(let ((hash (make-hash-table))) (set-hash-values hash ',(read-delimited-list #\} stream t)) hash)) (set-macro-character #\{ #'in-place-hash) (set-syntax-from-char #\} #\)) I just sketched these together. I am a CL noob. No doubt there are more concise approaches.