|
|
|
|
@ -32,11 +32,25 @@ |
|
|
|
|
It should only be set using dynamic scope with a let, like: |
|
|
|
|
(let ((!compare-fn =)) (!union numbers1 numbers2 numbers3)") |
|
|
|
|
|
|
|
|
|
(defmacro !filter (form-or-fn list) |
|
|
|
|
`(let ((!--list ,list) |
|
|
|
|
(!--result '())) |
|
|
|
|
(while !--list |
|
|
|
|
(let ((it (car !--list))) |
|
|
|
|
(when ,(if (functionp form-or-fn) (list form-or-fn 'it) (list 'progn form-or-fn)) |
|
|
|
|
(setq !--result (cons it !--result)))) |
|
|
|
|
(setq !--list (cdr !--list))) |
|
|
|
|
(nreverse !--result))) |
|
|
|
|
|
|
|
|
|
(defmacro !map (form-or-fn list) |
|
|
|
|
(if (functionp form-or-fn) |
|
|
|
|
`(mapcar #',form-or-fn ,list) |
|
|
|
|
`(mapcar #'(lambda (it) ,form-or-fn) ,list))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun !concat (list) |
|
|
|
|
(apply 'concatenate 'list list)) |
|
|
|
|
|
|
|
|
|
(defalias '!map 'mapcar) |
|
|
|
|
|
|
|
|
|
(defalias '!select 'remove-if-not) |
|
|
|
|
(defalias '!reject 'remove-if) |
|
|
|
|
|
|
|
|
|
@ -45,16 +59,6 @@ It should only be set using dynamic scope with a let, like: |
|
|
|
|
(defun !mapcat (fn list) |
|
|
|
|
(!concat (!map fn list))) |
|
|
|
|
|
|
|
|
|
(defmacro !filter (form-or-fn list) |
|
|
|
|
`(let ((!--list ,list) |
|
|
|
|
(!--result '())) |
|
|
|
|
(while !--list |
|
|
|
|
(let ((it (car !--list))) |
|
|
|
|
(when ,(if (functionp form-or-fn) (list form-or-fn 'it) (list 'progn form-or-fn)) |
|
|
|
|
(setq !--result (cons it !--result)))) |
|
|
|
|
(setq !--list (cdr !--list))) |
|
|
|
|
(nreverse !--result))) |
|
|
|
|
|
|
|
|
|
(defun !uniq (list) |
|
|
|
|
"Return a new list with all duplicates removed. |
|
|
|
|
The test for equality is done with `equal', |
|
|
|
|
|