2017-08-21 14:29:45 +05:30
|
|
|
(library
|
|
|
|
(utils)
|
|
|
|
(export inc!
|
2017-08-23 15:19:36 +05:30
|
|
|
dec!
|
2017-08-24 18:39:23 +05:30
|
|
|
swap!)
|
2017-08-21 14:29:45 +05:30
|
|
|
(import (rnrs))
|
|
|
|
|
|
|
|
(define-syntax inc!
|
|
|
|
(syntax-rules ()
|
|
|
|
((_ v) (set! v (+ 1 v)))
|
|
|
|
((_ v n) (set! v (+ n v)))))
|
|
|
|
|
|
|
|
(define-syntax dec!
|
|
|
|
(syntax-rules ()
|
|
|
|
((_ v) (set! v (- v 1)))
|
|
|
|
((_ v n) (set! v (- v n)))))
|
2017-08-23 15:19:36 +05:30
|
|
|
|
|
|
|
(define-syntax swap!
|
|
|
|
(syntax-rules ()
|
|
|
|
((_ x y)
|
|
|
|
(let ((tmp x))
|
|
|
|
(set! x y)
|
|
|
|
(set! y tmp)))))
|
2017-08-21 14:29:45 +05:30
|
|
|
)
|