Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (:import-from :alexandria
- :assoc-value)
- (defparameter *issues*
- (let ((vector (make-array 0
- :fill-pointer 0
- :adjustable t
- :element-type 'list)))
- (vector-push-extend
- (pairlis '(:id :title :description :status)
- '(1 "Is working well!" "Blah blah blah" :open))
- vector)
- (vector-push-extend
- (pairlis '(:id :title :description :status)
- '(2 "That feature doesn't work!" "Bleh.." :closed))
- vector)
- (vector-push-extend
- (pairlis '(:id :title :description :status)
- '(3 "Found a bug!" "Bloh!" :open))
- vector)
- (vector-push-extend
- (pairlis '(:id :title :description :status)
- '(4 "Need something to do X!" "Need this ASAP!" :open))
- vector)
- vector))
- (defun remove-issue (issues id)
- "Remove an issue by ID"
- (remove-if #'(lambda (issue)
- (= id (assoc-value issue :id)))
- issues
- :count 1))
- (remove-issue *issues* 1)
- ; #(((:STATUS . :CLOSED) (:DESCRIPTION . "Bleh..") (:TITLE . "That feature doesn't work!") (:ID . 2)) ((:STATUS . :OPEN) (:DESCRIPTION . "Bloh!") (:TITLE . "Found a bug!") (:ID . 3)) ((:STATUS . :OPEN) (:DESCRIPTION . "Need this ASAP!") (:TITLE . "Need something to do X!") (:ID . 4)))
- (array-has-fill-pointer-p *issues*)
- ; T
- (setf *issues* (remove-issue *issues* 1))
- (array-has-fill-pointer-p *issues*)
- ; NIL
- (vector-push-extend
- (pairlis '(:id :title :description :status)
- '(9 "new!!" "different" :open))
- *issues*)
- ; The value #(((:STATUS . :CLOSED) (:DESCRIPTION . "Bleh..")
- ; (:TITLE . "That feature doesn't work!") (:ID . 2))
- ; ((:STATUS . :OPEN) (:DESCRIPTION . "Bloh!")
- ; (:TITLE . "Found a bug!") (:ID . 3))
- ; ((:STATUS . :OPEN)
- ; (:DESCRIPTION . "Need this ASAP!")
- ; (:TITLE . "Need something to do X!")
- ; (:ID . 4))) is not of the expected type (AND
- ; ARRAY
- ; (SATISFIES
- ; ARRAY-HAS-FILL-POINTER-P)).
- ; [Condition of type TYPE-ERROR]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement