From 71a75cd53090be3ec2704ad8d57d8a3b499a9c0c Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 5 Dec 2022 21:11:39 +0200 Subject: [collection] Added push-back, pop-back and slice functionality --- src/collections.lisp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/collections.lisp (limited to 'src/collections.lisp') diff --git a/src/collections.lisp b/src/collections.lisp new file mode 100644 index 0000000..4e7aae4 --- /dev/null +++ b/src/collections.lisp @@ -0,0 +1,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))) -- cgit v1.2.3