summaryrefslogtreecommitdiffhomepage
path: root/racket.html.markdown
diff options
context:
space:
mode:
authorEli Barzilay <eli@barzilay.org>2013-07-16 02:06:16 -0400
committerEli Barzilay <eli@barzilay.org>2013-07-16 02:06:16 -0400
commit7a92ee7ab8833ba3871387613ce14eb958aee11a (patch)
treeba7445c67e3fc00a117a6f10e109048eb129759f /racket.html.markdown
parentfbd215521f9b0439fc218957ee72f041bfde933b (diff)
`swap' -> `swap!'
Diffstat (limited to 'racket.html.markdown')
-rw-r--r--racket.html.markdown4
1 files changed, 2 insertions, 2 deletions
diff --git a/racket.html.markdown b/racket.html.markdown
index bf94db90..d43ac5e2 100644
--- a/racket.html.markdown
+++ b/racket.html.markdown
@@ -441,7 +441,7 @@ vec ; => #(1 2 3 4)
(set! i (add1 i))))
;; Macros are hygienic, you cannot clobber existing variables!
-(define-syntax-rule (swap x y)
+(define-syntax-rule (swap! x y) ; -! is idomatic for mutation
(let ([tmp x])
(set! x y)
(set! y tmp)))
@@ -449,7 +449,7 @@ vec ; => #(1 2 3 4)
(define tmp 1)
(define a 2)
(define b 3)
-(swap a b)
+(swap! a b)
(printf "tmp = ~a; a = ~a; b = ~a\n" tmp a b) ; tmp is unaffected
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;