| Paste number 23866: | The real example |
| Pasted by: | ignas |
| 2 years, 4 months ago | |
| #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 1: | the code that does the job |
| Pasted by: | ignas |
| 2 years, 4 months ago | |
| 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 _ _ _ _)))))) |
| Annotation number 2: | ignas, this should do the same |
| Pasted by: | attila |
| 2 years, 4 months ago | |
| 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 3: | the real thing this time |
| Pasted by: | attila |
| 2 years, 4 months ago | |
| 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 4: | ignas, a bit simplified |
| Pasted by: | attila |
| 2 years, 4 months ago | |
| 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))))) |