summaryrefslogtreecommitdiffhomepage
path: root/racket.html.markdown
diff options
context:
space:
mode:
authorEli Barzilay <eli@barzilay.org>2013-07-16 03:06:11 -0400
committerEli Barzilay <eli@barzilay.org>2013-07-16 03:06:11 -0400
commit547a8a6db1fb74a843bb0fbf1f81dd3d67eb92c4 (patch)
treec798f7bc1b83f32de5ccaa473cb3a93fcd4a9fb8 /racket.html.markdown
parent159b7e4e1e845304bd8eb4398677010b86c7f249 (diff)
Improve mutable/immutable comment, add `make-vector' example.
Diffstat (limited to 'racket.html.markdown')
-rw-r--r--racket.html.markdown9
1 files changed, 6 insertions, 3 deletions
diff --git a/racket.html.markdown b/racket.html.markdown
index fbd3f76a..90b29d21 100644
--- a/racket.html.markdown
+++ b/racket.html.markdown
@@ -365,13 +365,16 @@ n ; => 6
(set-box! n* (add1 (unbox n*)))
(unbox n*) ; => 6
-;; Many Racket datatypes can be immutable or mutable
-;; (Pairs, Lists, Strings, Vectors, Hash Tables, etc...)
+;; Many Racket datatypes are immutable (pairs, lists, etc), some come in
+;; both mutable and immutable flavors (strings, vectors, hash tables,
+;; etc...)
-;; Use `vector' to create a mutable vector
+;; Use `vector' or `make-vector' to create mutable vectors
(define vec (vector 2 2 3 4))
+(define wall (make-vector 100 'bottle-of-beer))
;; Use vector-set! to update a slot
(vector-set! vec 0 1)
+(vector-set! wall 99 'down)
vec ; => #(1 2 3 4)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;