|
|
|
|
@ -44,6 +44,8 @@ Include this in your emacs settings to get syntax highlighting: |
|
|
|
|
* [-map-when](#-map-when-pred-rep-list) `(pred rep list)` |
|
|
|
|
* [-replace](#-replace-old-new-list) `(old new list)` |
|
|
|
|
* [-map-indexed](#-map-indexed-fn-list) `(fn list)` |
|
|
|
|
* [-splice](#-splice-pred-fun-list) `(pred fun list)` |
|
|
|
|
* [-splice-list](#-splice-list-pred-new-list-list) `(pred new-list list)` |
|
|
|
|
* [-flatten](#-flatten-l) `(l)` |
|
|
|
|
* [-flatten-n](#-flatten-n-num-list) `(num list)` |
|
|
|
|
* [-concat](#-concat-rest-lists) `(&rest lists)` |
|
|
|
|
@ -309,6 +311,33 @@ In the anaphoric form `--map-indexed`, the index is exposed as `it-index`. |
|
|
|
|
(--map-indexed (- it it-index) '(1 2 3 4)) ;; => '(1 1 1 1) |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
#### -splice `(pred fun list)` |
|
|
|
|
|
|
|
|
|
Splice lists generated by `fun` in place of elements matching `pred` in `list`. |
|
|
|
|
|
|
|
|
|
`fun` takes the element matching `pred` as input. |
|
|
|
|
|
|
|
|
|
This function can be used as replacement for `,@` in case you |
|
|
|
|
need to splice several lists at marked positions (for example |
|
|
|
|
with keywords). |
|
|
|
|
|
|
|
|
|
```cl |
|
|
|
|
(-splice 'even? (lambda (x) (list x x)) '(1 2 3 4)) ;; => '(1 2 2 3 4 4) |
|
|
|
|
(--splice 't (list it it) '(1 2 3 4)) ;; => '(1 1 2 2 3 3 4 4) |
|
|
|
|
(--splice (equal it :magic) '((list of) (magical) (code)) '((foo) (bar) :magic (baz))) ;; => '((foo) (bar) (list of) (magical) (code) (baz)) |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
#### -splice-list `(pred new-list list)` |
|
|
|
|
|
|
|
|
|
Splice `new-list` in place of elements matching `pred` in `list`. |
|
|
|
|
|
|
|
|
|
See also more general version: `-splice`. |
|
|
|
|
|
|
|
|
|
```cl |
|
|
|
|
(-splice-list 'keywordp '(a b c) '(1 :foo 2)) ;; => '(1 a b c 2) |
|
|
|
|
(-splice-list 'keywordp nil '(1 :foo 2)) ;; => '(1 2) |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
#### -flatten `(l)` |
|
|
|
|
|
|
|
|
|
Takes a nested list `l` and returns its contents as a single, flat list. |
|
|
|
|
|