[ prog / sol / mona ]

prog


Post macros.

25 2020-06-06 01:24

> 20

These are amazing, thank you!

FWIW here are my DEFINE-SYNTAX versions of the above-mentioned PUSH!, POP!, INCF!, DECF!. They are trivial but this might be useful for beginners to see how to translate from DEFINE-MACRO:

(define-syntax push!
  (syntax-rules ()
    ((push! item seq)
     (begin (set! seq (cons item seq))
            seq))))

(define-syntax pop!
  (syntax-rules ()
    ((pop! seq)
     (let ((result (car seq)))
       (begin (set! seq (cdr seq))
              result)))))

(define-syntax incf!
  (syntax-rules ()
    ((incf! var)
     (begin (set! var (+ 1 var))
            var))))

(define-syntax decf!
  (syntax-rules ()
    ((decf! var)
     (begin (set! var (- var 1))
            var))))
40


VIP:

do not edit these