diff options
| author | Syndamia <kamen@syndamia.com> | 2022-12-05 21:11:39 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2022-12-05 21:11:39 +0200 |
| commit | 71a75cd53090be3ec2704ad8d57d8a3b499a9c0c (patch) | |
| tree | ac9e7082123aa9123655c802b6dcf65bc7ffb2ec | |
| parent | 5046209659500c82329774fbfd4d6f400e90b8e2 (diff) | |
| download | senzill-71a75cd53090be3ec2704ad8d57d8a3b499a9c0c.tar senzill-71a75cd53090be3ec2704ad8d57d8a3b499a9c0c.tar.gz senzill-71a75cd53090be3ec2704ad8d57d8a3b499a9c0c.zip | |
[collection] Added push-back, pop-back and slice functionality
| -rw-r--r-- | src/collections.lisp | 15 |
1 files changed, 15 insertions, 0 deletions
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))) |
