| Paste number 23866: | The real example |
| Pasted by: | ignas |
| When: | 2 years, 10 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+IEY |
| Channel: | #lisp |
| Paste contents: |
(test (make-field)
(is (equal (macroexpand-1
'(make-field (s s _ _)
(_ s s _)
(_ _ _ _)
(_ _ b b)
(_ _ b b)
(_ _ _ _)))
'(make-field-stub `((,s ,s ,_ ,_)
(,_ ,s ,s ,_)
(,_ ,_ ,_ ,_)
(,_ ,_ ,b ,b)
(,_ ,_ ,b ,b)
(,_ ,_ ,_ ,_))))))Annotations for this paste:
| Annotation number 4: | ignas, a bit simplified |
| Pasted by: | attila |
| When: | 2 years, 10 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+IEY#4 |
| Paste contents: |
;;; the inner backquoting was unnecessary
(defmacro make-field (&rest contents)
`(make-field-stub `(,@,(loop for row in contents
collect (loop for cell in row
collect cell)))))| Annotation number 3: | the real thing this time |
| Pasted by: | attila |
| When: | 2 years, 10 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+IEY#3 |
| Paste contents: |
(defmacro make-field (&rest contents)
`(make-field-stub `(,@,(loop for row in contents
collect `(,@(loop for cell in row
collect cell))))))| Annotation number 2: | ignas, this should do the same |
| Pasted by: | attila |
| When: | 2 years, 10 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+IEY#2 |
| Paste contents: |
;;; should do the same, although the list variant is more
;;; readable in this situation, imho
(test (make-field)
(is (equal (macroexpand-1
'(make-field (s s _ _)
(_ s s _)
(_ _ _ _)
(_ _ b b)
(_ _ b b)
(_ _ _ _)))
'`(make-field-stub ((,s ,s ,_ ,_)
(,_ ,s ,s ,_)
(,_ ,_ ,_ ,_)
(,_ ,_ ,b ,b)
(,_ ,_ ,b ,b)
(,_ ,_ ,_ ,_))))))| Annotation number 1: | the code that does the job |
| Pasted by: | ignas |
| When: | 2 years, 10 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+IEY#1 |
| Paste contents: |
(defmacro make-field (&rest contents)
`(make-field-stub (list
,@(loop for row in contents
collect `(list ,@(loop for cell in row
collect cell))))))
(test (make-field)
(is (equal (macroexpand-1
'(make-field (s s _ _)
(_ s s _)
(_ _ _ _)
(_ _ b b)
(_ _ b b)
(_ _ _ _)))
'(make-field-stub (list (list s s _ _)
(list _ s s _)
(list _ _ _ _)
(list _ _ b b)
(list _ _ b b)
(list _ _ _ _))))))