Merge pull request #267 from Goheeca/patch-1

Typos and adjustable vectors
This commit is contained in:
Adam Bard 2013-08-27 20:58:46 -07:00
commit d70526b1ad

View File

@ -205,7 +205,7 @@ nil ; for false - and the empty list
;; Or use concatenate - ;; 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 ;; Lists are a very central type, so there is a wide variety of functionality for
;; them, a few examples: ;; them, a few examples:
@ -219,7 +219,7 @@ nil ; for false - and the empty list
;;; Vectors ;;; Vectors
;; Vectors are fixed-length arrays ;; Vector's literals are fixed-length arrays
#(1 2 3) ; => #(1 2 3) #(1 2 3) ; => #(1 2 3)
;; Use concatenate to add vectors together ;; Use concatenate to add vectors together
@ -253,6 +253,23 @@ nil ; for false - and the empty list
; => 0 ; => 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: ;;; Naively, sets are just lists:
(set-difference '(1 2 3 4) '(4 5 6 7)) ; => (3 2 1) (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. ;; not.
;; Retrieving a non-present value returns nil ;; 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 ;; 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. ;; Let's handle the multiple return values here in code.
@ -457,8 +474,8 @@ nil ; for false - and the empty list
:accessor velocity :accessor velocity
:initarg :velocity) :initarg :velocity)
(average-efficiency (average-efficiency
:accessor average-efficiency) :accessor average-efficiency
:initarg :average-efficiency) :initarg :average-efficiency))
(:documentation "A human powered conveyance")) (:documentation "A human powered conveyance"))
;; defclass, followed by name, followed by the superclass list, ;; 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 superclasses: STANDARD-OBJECT
; Direct subclasses: UNICYCLE, BICYCLE, CANOE ; Direct subclasses: UNICYCLE, BICYCLE, CANOE
; Not yet finalized. ; Not yet finalized.
(defparameter *foo#\u03BBooo* nil) ; Direct slots: ; Direct slots:
; VELOCITY ; VELOCITY
; Readers: VELOCITY ; Readers: VELOCITY
; Writers: (SETF VELOCITY) ; Writers: (SETF VELOCITY)