diff --git a/kutils.lisp b/kutils.lisp index 99d946b..6439557 100644 --- a/kutils.lisp +++ b/kutils.lisp @@ -6,6 +6,15 @@ ;;; This file contains various utilities I've written. +(defun take (n lst) + "Take n elements from lst." + (labels ((rec (n lst acc) + (if (or (zerop n) (null lst)) + (nreverse acc) + (rec (- n 1) (cdr lst) (cons (car lst) acc))))) + (when (> n 0) + (rec n lst nil)))) + (defun interpose (x sep) "Takes a list and a separator, and places separator between element of the list." diff --git a/package.lisp b/package.lisp index ab03a7c..5174cc4 100644 --- a/package.lisp +++ b/package.lisp @@ -9,13 +9,14 @@ #:compose #:defmacro! ; Let Over Lambda utilities #:interpose ; My utilities + #:take #:build-list #:partial #:macroexpand-n #:mksymb #:mkkw #:defclass! - #:zip + #:zip #:enable-hash-table-reader #:hashkeys #:sethash