aboutsummaryrefslogtreecommitdiff
path: root/src/collections.lisp
blob: b0da74f33ee6e0124068ffc2e6dc7881e41a4f9d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
(in-package :senzill.collections)

(defmacro push-back (item place)
  "Item is appended to the (right) end of the place (list)"
  `(setf ,place (append ,place (list ,item))))

(defmacro pop-back (place)
  "Removes destructively last element and returns it"
  `(let ((val (car (last ,place))))
     (setq ,place (nbutlast ,place))
     val))

(defun slice (place &key (begin 0) (end (length place)))
  "Returns list of elements from begin to end indecies, inclusive"
  (butlast (nthcdr begin place) (- (length place) end 1)))