aboutsummaryrefslogtreecommitdiff
path: root/src/collections.lisp
blob: 4e7aae49fb55f9d0fbb7831f5d709778e6d62669 (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"
  `(progn (let ((val (car (last ,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)))