summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdam Bard <github@adambard.com>2013-08-27 20:58:46 -0700
committerAdam Bard <github@adambard.com>2013-08-27 20:58:46 -0700
commitd70526b1ad7b8207b85fb6f2b56b6f4f85f64c3f (patch)
treed6c21e59bda21ccbf1fa0121dd7e5672ee4aaa74
parent7570ef6862854543061448958311854599b1b0e9 (diff)
parentedf839bfaefcdeb567ead6af0572d1e5195b4a3d (diff)
Merge pull request #267 from Goheeca/patch-1
Typos and adjustable vectors
-rw-r--r--common-lisp.html.markdown31
1 files changed, 24 insertions, 7 deletions
diff --git a/common-lisp.html.markdown b/common-lisp.html.markdown
index a917304c..bf4844f3 100644
--- a/common-lisp.html.markdown
+++ b/common-lisp.html.markdown
@@ -205,7 +205,7 @@ nil ; for false - and the empty list
;; Or use concatenate -
-(concatenate
+(concatenate 'list '(1 2) '(3 4))
;; Lists are a very central type, so there is a wide variety of functionality for
;; them, a few examples:
@@ -219,7 +219,7 @@ nil ; for false - and the empty list
;;; Vectors
-;; Vectors are fixed-length arrays
+;; Vector's literals are fixed-length arrays
#(1 2 3) ; => #(1 2 3)
;; Use concatenate to add vectors together
@@ -253,6 +253,23 @@ nil ; for false - and the empty list
; => 0
+;;; Adjustable vectors
+
+;; Adjustable vectors have the same printed representation
+;; as fixed-length vector's literals.
+
+(defparameter *adjvec* (make-array '(3) :initial-contents '(1 2 3)
+ :adjustable t :fill-pointer t))
+
+*adjvec* ; => #(1 2 3)
+
+;; Adding new element:
+(vector-push-extend 4 *adjvec*) ; => 3
+
+*adjvec* ; => #(1 2 3 4)
+
+
+
;;; Naively, sets are just lists:
(set-difference '(1 2 3 4) '(4 5 6 7)) ; => (3 2 1)
@@ -279,10 +296,10 @@ nil ; for false - and the empty list
;; not.
;; Retrieving a non-present value returns nil
- (gethash *m* 'd) ;=> nil, nil
+ (gethash 'd *m*) ;=> nil, nil
;; You can provide a default value for missing keys
-(gethash *m* 'd :not-found) ; => :NOT-FOUND
+(gethash 'd *m* :not-found) ; => :NOT-FOUND
;; Let's handle the multiple return values here in code.
@@ -457,8 +474,8 @@ nil ; for false - and the empty list
:accessor velocity
:initarg :velocity)
(average-efficiency
- :accessor average-efficiency)
- :initarg :average-efficiency)
+ :accessor average-efficiency
+ :initarg :average-efficiency))
(:documentation "A human powered conveyance"))
;; defclass, followed by name, followed by the superclass list,
@@ -506,7 +523,7 @@ nil ; for false - and the empty list
; Direct superclasses: STANDARD-OBJECT
; Direct subclasses: UNICYCLE, BICYCLE, CANOE
; Not yet finalized.
-(defparameter *foo#\u03BBooo* nil) ; Direct slots:
+; Direct slots:
; VELOCITY
; Readers: VELOCITY
; Writers: (SETF VELOCITY)