Add TAKE.
This commit is contained in:
parent
19c7d9afbd
commit
131b9848e9
|
@ -6,6 +6,15 @@
|
||||||
|
|
||||||
;;; This file contains various utilities I've written.
|
;;; 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)
|
(defun interpose (x sep)
|
||||||
"Takes a list and a separator, and places separator between element
|
"Takes a list and a separator, and places separator between element
|
||||||
of the list."
|
of the list."
|
||||||
|
|
|
@ -9,13 +9,14 @@
|
||||||
#:compose
|
#:compose
|
||||||
#:defmacro! ; Let Over Lambda utilities
|
#:defmacro! ; Let Over Lambda utilities
|
||||||
#:interpose ; My utilities
|
#:interpose ; My utilities
|
||||||
|
#:take
|
||||||
#:build-list
|
#:build-list
|
||||||
#:partial
|
#:partial
|
||||||
#:macroexpand-n
|
#:macroexpand-n
|
||||||
#:mksymb
|
#:mksymb
|
||||||
#:mkkw
|
#:mkkw
|
||||||
#:defclass!
|
#:defclass!
|
||||||
#:zip
|
#:zip
|
||||||
#:enable-hash-table-reader
|
#:enable-hash-table-reader
|
||||||
#:hashkeys
|
#:hashkeys
|
||||||
#:sethash
|
#:sethash
|
||||||
|
|
Loading…
Reference in New Issue