Add TAKE.

This commit is contained in:
Kyle Isom 2015-04-20 20:38:05 -07:00
parent 19c7d9afbd
commit 131b9848e9
2 changed files with 11 additions and 1 deletions

View File

@ -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."

View File

@ -9,6 +9,7 @@
#:compose
#:defmacro! ; Let Over Lambda utilities
#:interpose ; My utilities
#:take
#:build-list
#:partial
#:macroexpand-n