Merge pull request #240 from basil-conto/239

Replace -first with -some in -any?
master
Magnar Sveen 9 years ago committed by GitHub
commit c026c46527
  1. 75
      README.md
  2. 2
      dash.el
  3. 439
      dash.info
  4. 117
      dash.texi
  5. 6
      dev/examples.el

@ -179,6 +179,10 @@ Functions partitioning the input list into a list of lists.
* [-partition-all-in-steps](#-partition-all-in-steps-n-step-list) `(n step list)` * [-partition-all-in-steps](#-partition-all-in-steps-n-step-list) `(n step list)`
* [-partition-by](#-partition-by-fn-list) `(fn list)` * [-partition-by](#-partition-by-fn-list) `(fn list)`
* [-partition-by-header](#-partition-by-header-fn-list) `(fn list)` * [-partition-by-header](#-partition-by-header-fn-list) `(fn list)`
* [-partition-after-pred](#-partition-after-pred-pred-list) `(pred list)`
* [-partition-before-pred](#-partition-before-pred-pred-list) `(pred list)`
* [-partition-before-item](#-partition-before-item-item-list) `(item list)`
* [-partition-after-item](#-partition-after-item-item-list) `(item list)`
* [-group-by](#-group-by-fn-list) `(fn list)` * [-group-by](#-group-by-fn-list) `(fn list)`
### Indexing ### Indexing
@ -372,7 +376,7 @@ See also: [`-map-when`](#-map-when-pred-rep-list), [`-replace-last`](#-replace-l
Return a new list consisting of the result of (`fn` index item) for each item in `list`. Return a new list consisting of the result of (`fn` index item) for each item in `list`.
In the anaphoric form `--map-indexed`, the index is exposed as `it-index`. In the anaphoric form `--map-indexed`, the index is exposed as symbol `it-index`.
See also: [`-each-indexed`](#-each-indexed-list-fn). See also: [`-each-indexed`](#-each-indexed-list-fn).
@ -655,7 +659,7 @@ See also: [`-select-columns`](#-select-columns-columns-table), [`-select-by-indi
## List to list ## List to list
Bag of various functions which modify input list. Functions returning a modified copy of the input list.
#### -keep `(fn list)` #### -keep `(fn list)`
@ -828,7 +832,7 @@ item, etc. If `list` contains no items, return `initial-value` and
`fn` is not called. `fn` is not called.
In the anaphoric form `--reduce-from`, the accumulated value is In the anaphoric form `--reduce-from`, the accumulated value is
exposed as `acc`. exposed as symbol `acc`.
See also: [`-reduce`](#-reduce-fn-list), [`-reduce-r`](#-reduce-r-fn-list) See also: [`-reduce`](#-reduce-fn-list), [`-reduce-r`](#-reduce-r-fn-list)
@ -864,7 +868,7 @@ reduce return the result of calling `fn` with no arguments. If
`list` has only 1 item, it is returned and `fn` is not called. `list` has only 1 item, it is returned and `fn` is not called.
In the anaphoric form `--reduce`, the accumulated value is In the anaphoric form `--reduce`, the accumulated value is
exposed as `acc`. exposed as symbol `acc`.
See also: [`-reduce-from`](#-reduce-from-fn-initial-value-list), [`-reduce-r`](#-reduce-r-fn-list) See also: [`-reduce-from`](#-reduce-from-fn-initial-value-list), [`-reduce-r`](#-reduce-r-fn-list)
@ -1025,7 +1029,7 @@ Alias: `-any-p`, `-some?`, `-some-p`
```el ```el
(-any? 'even? '(1 2 3)) ;; => t (-any? 'even? '(1 2 3)) ;; => t
(-any? 'even? '(1 3 5)) ;; => nil (-any? 'even? '(1 3 5)) ;; => nil
(--any? (= 0 (% it 2)) '(1 2 3)) ;; => t (-any? 'null '(1 3 5)) ;; => nil
``` ```
#### -all? `(pred list)` #### -all? `(pred list)`
@ -1269,6 +1273,46 @@ other value (the body).
(-partition-by-header 'even? '(2 1 1 1 4 1 3 5 6 6 1)) ;; => '((2 1 1 1) (4 1 3 5) (6 6 1)) (-partition-by-header 'even? '(2 1 1 1 4 1 3 5 6 6 1)) ;; => '((2 1 1 1) (4 1 3 5) (6 6 1))
``` ```
#### -partition-after-pred `(pred list)`
Partition directly after each time `pred` is true on an element of `list`.
```el
(-partition-after-pred (function oddp) '()) ;; => '()
(-partition-after-pred (function oddp) '(1)) ;; => '((1))
(-partition-after-pred (function oddp) '(0 1)) ;; => '((0 1))
```
#### -partition-before-pred `(pred list)`
Partition directly before each time `pred` is true on an element of `list`.
```el
(-partition-before-pred (function oddp) '()) ;; => '()
(-partition-before-pred (function oddp) '(1)) ;; => '((1))
(-partition-before-pred (function oddp) '(0 1)) ;; => '((0) (1))
```
#### -partition-before-item `(item list)`
Partition directly before each time `item` appears in `list`.
```el
(-partition-before-item 3 '()) ;; => '()
(-partition-before-item 3 '(1)) ;; => '((1))
(-partition-before-item 3 '(3)) ;; => '((3))
```
#### -partition-after-item `(item list)`
Partition directly after each time `item` appears in `list`.
```el
(-partition-after-item 3 '()) ;; => '()
(-partition-after-item 3 '(1)) ;; => '((1))
(-partition-after-item 3 '(3)) ;; => '((3))
```
#### -group-by `(fn list)` #### -group-by `(fn list)`
Separate `list` into an alist whose keys are `fn` applied to the Separate `list` into an alist whose keys are `fn` applied to the
@ -1526,8 +1570,8 @@ function is applied pairwise taking as first argument element of
`list1` and as second argument element of `list2` at corresponding `list1` and as second argument element of `list2` at corresponding
position. position.
The anaphoric form `--zip-with` binds the elements from `list1` as `it`, The anaphoric form `--zip-with` binds the elements from `list1` as symbol `it`,
and the elements from `list2` as `other`. and the elements from `list2` as symbol `other`.
```el ```el
(-zip-with '+ '(1 2 3) '(4 5 6)) ;; => '(5 7 9) (-zip-with '+ '(1 2 3) '(4 5 6)) ;; => '(5 7 9)
@ -1657,7 +1701,7 @@ Alias: `-find`
```el ```el
(-first 'even? '(1 2 3)) ;; => 2 (-first 'even? '(1 2 3)) ;; => 2
(-first 'even? '(1 3 5)) ;; => nil (-first 'even? '(1 3 5)) ;; => nil
(--first (> it 2) '(1 2 3)) ;; => 3 (-first 'null '(1 3 5)) ;; => nil
``` ```
#### -some `(pred list)` #### -some `(pred list)`
@ -1668,8 +1712,8 @@ Alias: `-any`
```el ```el
(-some 'even? '(1 2 3)) ;; => t (-some 'even? '(1 2 3)) ;; => t
(--some (member 'foo it) '((foo bar) (baz))) ;; => '(foo bar) (-some 'null '(1 2 3)) ;; => nil
(--some (plist-get it :bar) '((:foo 1 :bar 2) (:baz 3))) ;; => 2 (-some 'null '(1 2 nil)) ;; => t
``` ```
#### -last `(pred list)` #### -last `(pred list)`
@ -1911,7 +1955,7 @@ last item in second form, etc.
Starting with the value of `x`, thread each expression through `forms`. Starting with the value of `x`, thread each expression through `forms`.
Insert `x` at the position signified by the token `it` in the first Insert `x` at the position signified by the symbol `it` in the first
form. If there are more forms, insert the first form at the position form. If there are more forms, insert the first form at the position
signified by `it` in in second form, etc. signified by `it` in in second form, etc.
@ -1976,10 +2020,11 @@ Convenient versions of `let` and `let*` constructs combined with flow control.
#### -when-let `(var-val &rest body)` #### -when-let `(var-val &rest body)`
If `val` evaluates to non-nil, bind it to `var` and execute body. If `val` evaluates to non-nil, bind it to `var` and execute body.
`var-val` should be a (`var` `val`) pair.
Note: binding is done according to [`-let`](#-let-varlist-rest-body). Note: binding is done according to [`-let`](#-let-varlist-rest-body).
(fn (`var` `val`) &rest `body`)
```el ```el
(-when-let (match-index (string-match "d" "abcd")) (+ match-index 2)) ;; => 5 (-when-let (match-index (string-match "d" "abcd")) (+ match-index 2)) ;; => 5
(-when-let ((&plist :foo foo) (list :foo "foo")) foo) ;; => "foo" (-when-let ((&plist :foo foo) (list :foo "foo")) foo) ;; => "foo"
@ -2004,10 +2049,12 @@ encountered.
#### -if-let `(var-val then &rest else)` #### -if-let `(var-val then &rest else)`
If `val` evaluates to non-nil, bind it to `var` and do `then`, If `val` evaluates to non-nil, bind it to `var` and do `then`,
otherwise do `else`. `var-val` should be a (`var` `val`) pair. otherwise do `else`.
Note: binding is done according to [`-let`](#-let-varlist-rest-body). Note: binding is done according to [`-let`](#-let-varlist-rest-body).
(fn (`var` `val`) `then` &rest `else`)
```el ```el
(-if-let (match-index (string-match "d" "abc")) (+ match-index 3) 7) ;; => 7 (-if-let (match-index (string-match "d" "abc")) (+ match-index 3) 7) ;; => 7
(--if-let (even? 4) it nil) ;; => t (--if-let (even? 4) it nil) ;; => t
@ -2237,7 +2284,7 @@ Return nil, used for side-effects only.
Call (`fn` index item) for each item in `list`. Call (`fn` index item) for each item in `list`.
In the anaphoric form `--each-indexed`, the index is exposed as `it-index`. In the anaphoric form `--each-indexed`, the index is exposed as symbol `it-index`.
See also: [`-map-indexed`](#-map-indexed-fn-list). See also: [`-map-indexed`](#-map-indexed-fn-list).

@ -629,7 +629,7 @@ Alias: `-any'"
(defmacro --any? (form list) (defmacro --any? (form list)
"Anaphoric form of `-any?'." "Anaphoric form of `-any?'."
(declare (debug (form form))) (declare (debug (form form)))
`(---truthy? (--first ,form ,list))) `(---truthy? (--some ,form ,list)))
(defun -any? (pred list) (defun -any? (pred list)
"Return t if (PRED x) is non-nil for any x in LIST, else nil. "Return t if (PRED x) is non-nil for any x in LIST, else nil.

@ -1,4 +1,4 @@
This is dash.info, produced by makeinfo version 6.1 from dash.texi. This is dash.info, produced by makeinfo version 6.5 from dash.texi.
This manual is for ‘dash.el’ version 2.12.1. This manual is for ‘dash.el’ version 2.12.1.
@ -253,7 +253,7 @@ The results are collected in order and returned as new list.
each item in LIST. each item in LIST.
In the anaphoric form ‘--map-indexed’, the index is exposed as In the anaphoric form ‘--map-indexed’, the index is exposed as
‘it-index‘. symbol ‘it-index’.
See also: ‘-each-indexed’ (*note -each-indexed::). See also: ‘-each-indexed’ (*note -each-indexed::).
@ -726,7 +726,7 @@ Functions reducing lists into single value.
not called. not called.
In the anaphoric form ‘--reduce-from’, the accumulated value is In the anaphoric form ‘--reduce-from’, the accumulated value is
exposed as ‘acc‘. exposed as symbol ‘acc’.
See also: ‘-reduce’ (*note -reduce::), ‘-reduce-r’ (*note See also: ‘-reduce’ (*note -reduce::), ‘-reduce-r’ (*note
-reduce-r::) -reduce-r::)
@ -765,7 +765,7 @@ Functions reducing lists into single value.
LIST has only 1 item, it is returned and FN is not called. LIST has only 1 item, it is returned and FN is not called.
In the anaphoric form ‘--reduce’, the accumulated value is In the anaphoric form ‘--reduce’, the accumulated value is
exposed as ‘acc‘. exposed as symbol ‘acc’.
See also: ‘-reduce-from’ (*note -reduce-from::), ‘-reduce-r’ See also: ‘-reduce-from’ (*note -reduce-from::), ‘-reduce-r’
(*note -reduce-r::) (*note -reduce-r::)
@ -935,8 +935,8 @@ File: dash.info, Node: Predicates, Next: Partitioning, Prev: Unfolding, Up:
⇒ t ⇒ t
(-any? 'even? '(1 3 5)) (-any? 'even? '(1 3 5))
⇒ nil ⇒ nil
(--any? (= 0 (% it 2)) '(1 2 3)) (-any? 'null '(1 3 5))
t nil
-- Function: -all? (pred list) -- Function: -all? (pred list)
Return t if (PRED x) is non-nil for all x in LIST, else nil. Return t if (PRED x) is non-nil for all x in LIST, else nil.
@ -1189,6 +1189,48 @@ Functions partitioning the input list into a list of lists.
(-partition-by-header 'even? '(2 1 1 1 4 1 3 5 6 6 1)) (-partition-by-header 'even? '(2 1 1 1 4 1 3 5 6 6 1))
⇒ '((2 1 1 1) (4 1 3 5) (6 6 1)) ⇒ '((2 1 1 1) (4 1 3 5) (6 6 1))
-- Function: -partition-after-pred (pred list)
Partition directly after each time PRED is true on an element of
LIST.
(-partition-after-pred (function oddp) '())
⇒ '()
(-partition-after-pred (function oddp) '(1))
⇒ '((1))
(-partition-after-pred (function oddp) '(0 1))
⇒ '((0 1))
-- Function: -partition-before-pred (pred list)
Partition directly before each time PRED is true on an element of
LIST.
(-partition-before-pred (function oddp) '())
⇒ '()
(-partition-before-pred (function oddp) '(1))
⇒ '((1))
(-partition-before-pred (function oddp) '(0 1))
⇒ '((0) (1))
-- Function: -partition-before-item (item list)
Partition directly before each time ITEM appears in LIST.
(-partition-before-item 3 '())
⇒ '()
(-partition-before-item 3 '(1))
⇒ '((1))
(-partition-before-item 3 '(3))
⇒ '((3))
-- Function: -partition-after-item (item list)
Partition directly after each time ITEM appears in LIST.
(-partition-after-item 3 '())
⇒ '()
(-partition-after-item 3 '(1))
⇒ '((1))
(-partition-after-item 3 '(3))
⇒ '((3))
-- Function: -group-by (fn list) -- Function: -group-by (fn list)
Separate LIST into an alist whose keys are FN applied to the Separate LIST into an alist whose keys are FN applied to the
elements of LIST. Keys are compared by ‘equal’. elements of LIST. Keys are compared by ‘equal’.
@ -1449,7 +1491,7 @@ Other list functions not fit to be classified elsewhere.
position. position.
The anaphoric form ‘--zip-with’ binds the elements from LIST1 as The anaphoric form ‘--zip-with’ binds the elements from LIST1 as
‘it‘, and the elements from LIST2 as ‘other‘. symbol ‘it’, and the elements from LIST2 as symbol ‘other’.
(-zip-with '+ '(1 2 3) '(4 5 6)) (-zip-with '+ '(1 2 3) '(4 5 6))
⇒ '(5 7 9) ⇒ '(5 7 9)
@ -1581,8 +1623,8 @@ Other list functions not fit to be classified elsewhere.
⇒ 2 ⇒ 2
(-first 'even? '(1 3 5)) (-first 'even? '(1 3 5))
⇒ nil ⇒ nil
(--first (> it 2) '(1 2 3)) (-first 'null '(1 3 5))
3 nil
-- Function: -some (pred list) -- Function: -some (pred list)
Return (PRED x) for the first LIST item where (PRED x) is Return (PRED x) for the first LIST item where (PRED x) is
@ -1592,10 +1634,10 @@ Other list functions not fit to be classified elsewhere.
(-some 'even? '(1 2 3)) (-some 'even? '(1 2 3))
⇒ t ⇒ t
(--some (member 'foo it) '((foo bar) (baz))) (-some 'null '(1 2 3))
'(foo bar) nil
(--some (plist-get it :bar) '((:foo 1 :bar 2) (:baz 3))) (-some 'null '(1 2 nil))
2 t
-- Function: -last (pred list) -- Function: -last (pred list)
Return the last x in LIST where (PRED x) is non-nil, else nil. Return the last x in LIST where (PRED x) is non-nil, else nil.
@ -1842,9 +1884,9 @@ File: dash.info, Node: Threading macros, Next: Binding, Prev: Tree operations
Starting with the value of X, thread each expression through Starting with the value of X, thread each expression through
FORMS. FORMS.
Insert X at the position signified by the token ‘it’ in the first Insert X at the position signified by the symbol ‘it’ in the
form. If there are more forms, insert the first form at the first form. If there are more forms, insert the first form at
position signified by ‘it’ in in second form, etc. the position signified by ‘it’ in in second form, etc.
(--> "def" (concat "abc" it "ghi")) (--> "def" (concat "abc" it "ghi"))
⇒ "abcdefghi" ⇒ "abcdefghi"
@ -1913,10 +1955,11 @@ control.
-- Macro: -when-let (var-val &rest body) -- Macro: -when-let (var-val &rest body)
If VAL evaluates to non-nil, bind it to VAR and execute body. If VAL evaluates to non-nil, bind it to VAR and execute body.
VAR-VAL should be a (VAR VAL) pair.
Note: binding is done according to ‘-let’ (*note -let::). Note: binding is done according to ‘-let’ (*note -let::).
(fn (VAR VAL) &rest BODY)
(-when-let (match-index (string-match "d" "abcd")) (+ match-index 2)) (-when-let (match-index (string-match "d" "abcd")) (+ match-index 2))
⇒ 5 ⇒ 5
(-when-let ((&plist :foo foo) (list :foo "foo")) foo) (-when-let ((&plist :foo foo) (list :foo "foo")) foo)
@ -1940,10 +1983,12 @@ control.
-- Macro: -if-let (var-val then &rest else) -- Macro: -if-let (var-val then &rest else)
If VAL evaluates to non-nil, bind it to VAR and do THEN, If VAL evaluates to non-nil, bind it to VAR and do THEN,
otherwise do ELSE. VAR-VAL should be a (VAR VAL) pair. otherwise do ELSE.
Note: binding is done according to ‘-let’ (*note -let::). Note: binding is done according to ‘-let’ (*note -let::).
(fn (VAR VAL) THEN &rest ELSE)
(-if-let (match-index (string-match "d" "abc")) (+ match-index 3) 7) (-if-let (match-index (string-match "d" "abc")) (+ match-index 3) 7)
⇒ 7 ⇒ 7
(--if-let (even? 4) it nil) (--if-let (even? 4) it nil)
@ -2174,7 +2219,7 @@ Functions iterating over lists for side-effect only.
Call (FN index item) for each item in LIST. Call (FN index item) for each item in LIST.
In the anaphoric form ‘--each-indexed’, the index is exposed as In the anaphoric form ‘--each-indexed’, the index is exposed as
‘it-index‘. symbol ‘it-index’.
See also: ‘-map-indexed’ (*note -map-indexed::). See also: ‘-map-indexed’ (*note -map-indexed::).
@ -2713,9 +2758,9 @@ Index
(line 81) (line 81)
* -grade-down: Indexing. (line 81) * -grade-down: Indexing. (line 81)
* -grade-up: Indexing. (line 71) * -grade-up: Indexing. (line 71)
* -group-by: Partitioning. (line 145) * -group-by: Partitioning. (line 187)
* -if-let: Binding. (line 36) * -if-let: Binding. (line 37)
* -if-let*: Binding. (line 47) * -if-let*: Binding. (line 50)
* -insert-at: List to list. (line 109) * -insert-at: List to list. (line 109)
* -interleave: Other list operations. * -interleave: Other list operations.
(line 66) (line 66)
@ -2731,13 +2776,13 @@ Index
* -juxt: Function combinators. * -juxt: Function combinators.
(line 31) (line 31)
* -keep: List to list. (line 8) * -keep: List to list. (line 8)
* -lambda: Binding. (line 217) * -lambda: Binding. (line 220)
* -last: Other list operations. * -last: Other list operations.
(line 232) (line 232)
* -last-item: Other list operations. * -last-item: Other list operations.
(line 254) (line 254)
* -let: Binding. (line 63) * -let: Binding. (line 66)
* -let*: Binding. (line 197) * -let*: Binding. (line 200)
* -list: Other list operations. * -list: Other list operations.
(line 287) (line 287)
* -map: Maps. (line 10) * -map: Maps. (line 10)
@ -2764,8 +2809,12 @@ Index
* -partial: Function combinators. * -partial: Function combinators.
(line 9) (line 9)
* -partition: Partitioning. (line 74) * -partition: Partitioning. (line 74)
* -partition-after-item: Partitioning. (line 177)
* -partition-after-pred: Partitioning. (line 145)
* -partition-all: Partitioning. (line 86) * -partition-all: Partitioning. (line 86)
* -partition-all-in-steps: Partitioning. (line 109) * -partition-all-in-steps: Partitioning. (line 109)
* -partition-before-item: Partitioning. (line 167)
* -partition-before-pred: Partitioning. (line 156)
* -partition-by: Partitioning. (line 121) * -partition-by: Partitioning. (line 121)
* -partition-by-header: Partitioning. (line 132) * -partition-by-header: Partitioning. (line 132)
* -partition-in-steps: Partitioning. (line 97) * -partition-in-steps: Partitioning. (line 97)
@ -2836,7 +2885,7 @@ Index
(line 122) (line 122)
* -update-at: List to list. (line 133) * -update-at: List to list. (line 133)
* -when-let: Binding. (line 9) * -when-let: Binding. (line 9)
* -when-let*: Binding. (line 22) * -when-let*: Binding. (line 23)
* -zip: Other list operations. * -zip: Other list operations.
(line 93) (line 93)
* -zip-fill: Other list operations. * -zip-fill: Other list operations.
@ -2858,173 +2907,177 @@ Ref: -map-when5595
Ref: -map-first6178 Ref: -map-first6178
Ref: -map-last6656 Ref: -map-last6656
Ref: -map-indexed7129 Ref: -map-indexed7129
Ref: -annotate7602 Ref: -annotate7609
Ref: -splice8092 Ref: -splice8099
Ref: -splice-list8873 Ref: -splice-list8880
Ref: -mapcat9335 Ref: -mapcat9342
Ref: -copy9711 Ref: -copy9718
Node: Sublist selection9915 Node: Sublist selection9922
Ref: -filter10108 Ref: -filter10115
Ref: -remove10526 Ref: -remove10533
Ref: -remove-first10888 Ref: -remove-first10895
Ref: -remove-last11415 Ref: -remove-last11422
Ref: -remove-item11936 Ref: -remove-item11943
Ref: -non-nil12330 Ref: -non-nil12337
Ref: -slice12489 Ref: -slice12496
Ref: -take13021 Ref: -take13028
Ref: -take-last13329 Ref: -take-last13336
Ref: -drop13652 Ref: -drop13659
Ref: -drop-last13925 Ref: -drop-last13932
Ref: -take-while14185 Ref: -take-while14192
Ref: -drop-while14535 Ref: -drop-while14542
Ref: -select-by-indices14891 Ref: -select-by-indices14898
Ref: -select-columns15405 Ref: -select-columns15412
Ref: -select-column16110 Ref: -select-column16117
Node: List to list16573 Node: List to list16580
Ref: -keep16760 Ref: -keep16772
Ref: -concat17263 Ref: -concat17275
Ref: -flatten17560 Ref: -flatten17572
Ref: -flatten-n18319 Ref: -flatten-n18331
Ref: -replace18706 Ref: -replace18718
Ref: -replace-first19169 Ref: -replace-first19181
Ref: -replace-last19665 Ref: -replace-last19677
Ref: -insert-at20154 Ref: -insert-at20166
Ref: -replace-at20481 Ref: -replace-at20493
Ref: -update-at20876 Ref: -update-at20888
Ref: -remove-at21367 Ref: -remove-at21379
Ref: -remove-at-indices21855 Ref: -remove-at-indices21867
Node: Reductions22437 Node: Reductions22449
Ref: -reduce-from22606 Ref: -reduce-from22618
Ref: -reduce-r-from23385 Ref: -reduce-r-from23404
Ref: -reduce24170 Ref: -reduce24189
Ref: -reduce-r24971 Ref: -reduce-r24997
Ref: -count25887 Ref: -count25913
Ref: -sum26111 Ref: -sum26137
Ref: -product26300 Ref: -product26326
Ref: -min26509 Ref: -min26535
Ref: -min-by26735 Ref: -min-by26761
Ref: -max27258 Ref: -max27284
Ref: -max-by27483 Ref: -max-by27509
Node: Unfolding28011 Node: Unfolding28037
Ref: -iterate28250 Ref: -iterate28276
Ref: -unfold28695 Ref: -unfold28721
Node: Predicates29503 Node: Predicates29529
Ref: -any?29627 Ref: -any?29653
Ref: -all?29955 Ref: -all?29973
Ref: -none?30285 Ref: -none?30303
Ref: -only-some?30587 Ref: -only-some?30605
Ref: -contains?31072 Ref: -contains?31090
Ref: -same-items?31461 Ref: -same-items?31479
Ref: -is-prefix?31846 Ref: -is-prefix?31864
Ref: -is-suffix?32169 Ref: -is-suffix?32187
Ref: -is-infix?32492 Ref: -is-infix?32510
Node: Partitioning32846 Node: Partitioning32864
Ref: -split-at33034 Ref: -split-at33052
Ref: -split-with33319 Ref: -split-with33337
Ref: -split-on33722 Ref: -split-on33740
Ref: -split-when34398 Ref: -split-when34416
Ref: -separate35038 Ref: -separate35056
Ref: -partition35480 Ref: -partition35498
Ref: -partition-all35932 Ref: -partition-all35950
Ref: -partition-in-steps36360 Ref: -partition-in-steps36378
Ref: -partition-all-in-steps36857 Ref: -partition-all-in-steps36875
Ref: -partition-by37342 Ref: -partition-by37360
Ref: -partition-by-header37724 Ref: -partition-by-header37742
Ref: -group-by38328 Ref: -partition-after-pred38346
Node: Indexing38765 Ref: -partition-before-pred38717
Ref: -elem-index38967 Ref: -partition-before-item39095
Ref: -elem-indices39362 Ref: -partition-after-item39406
Ref: -find-index39745 Ref: -group-by39712
Ref: -find-last-index40234 Node: Indexing40149
Ref: -find-indices40738 Ref: -elem-index40351
Ref: -grade-up41146 Ref: -elem-indices40746
Ref: -grade-down41549 Ref: -find-index41129
Node: Set operations41959 Ref: -find-last-index41618
Ref: -union42142 Ref: -find-indices42122
Ref: -difference42584 Ref: -grade-up42530
Ref: -intersection43001 Ref: -grade-down42933
Ref: -powerset43438 Node: Set operations43343
Ref: -permutations43651 Ref: -union43526
Ref: -distinct43951 Ref: -difference43968
Node: Other list operations44275 Ref: -intersection44385
Ref: -rotate44500 Ref: -powerset44822
Ref: -repeat44795 Ref: -permutations45035
Ref: -cons*45058 Ref: -distinct45335
Ref: -snoc45445 Node: Other list operations45659
Ref: -interpose45858 Ref: -rotate45884
Ref: -interleave46156 Ref: -repeat46179
Ref: -zip-with46525 Ref: -cons*46442
Ref: -zip47228 Ref: -snoc46829
Ref: -zip-fill48034 Ref: -interpose47242
Ref: -unzip48357 Ref: -interleave47540
Ref: -cycle48891 Ref: -zip-with47909
Ref: -pad49264 Ref: -zip48626
Ref: -table49587 Ref: -zip-fill49432
Ref: -table-flat50377 Ref: -unzip49755
Ref: -first51386 Ref: -cycle50289
Ref: -some51760 Ref: -pad50662
Ref: -last52130 Ref: -table50985
Ref: -first-item52464 Ref: -table-flat51775
Ref: -last-item52777 Ref: -first52784
Ref: -butlast53069 Ref: -some53156
Ref: -sort53316 Ref: -last53465
Ref: -list53804 Ref: -first-item53799
Ref: -fix54135 Ref: -last-item54112
Node: Tree operations54675 Ref: -butlast54404
Ref: -tree-seq54871 Ref: -sort54651
Ref: -tree-map55729 Ref: -list55139
Ref: -tree-map-nodes56172 Ref: -fix55470
Ref: -tree-reduce57027 Node: Tree operations56010
Ref: -tree-reduce-from57909 Ref: -tree-seq56206
Ref: -tree-mapreduce58510 Ref: -tree-map57064
Ref: -tree-mapreduce-from59370 Ref: -tree-map-nodes57507
Ref: -clone60656 Ref: -tree-reduce58362
Node: Threading macros60984 Ref: -tree-reduce-from59244
Ref: ->61129 Ref: -tree-mapreduce59845
Ref: ->>61621 Ref: -tree-mapreduce-from60705
Ref: -->62126 Ref: -clone61991
Ref: -as->62686 Node: Threading macros62319
Ref: -some->63141 Ref: ->62464
Ref: -some->>63515 Ref: ->>62956
Ref: -some-->63951 Ref: -->63461
Node: Binding64422 Ref: -as->64022
Ref: -when-let64634 Ref: -some->64477
Ref: -when-let*65128 Ref: -some->>64851
Ref: -if-let65656 Ref: -some-->65287
Ref: -if-let*66051 Node: Binding65758
Ref: -let66668 Ref: -when-let65970
Ref: -let*71461 Ref: -when-let*66455
Ref: -lambda72402 Ref: -if-let66983
Node: Side-effects73204 Ref: -if-let*67378
Ref: -each73398 Ref: -let67995
Ref: -each-while73805 Ref: -let*72788
Ref: -each-indexed74165 Ref: -lambda73729
Ref: -dotimes74676 Node: Side-effects74531
Ref: -doto74979 Ref: -each74725
Node: Destructive operations75406 Ref: -each-while75132
Ref: !cons75579 Ref: -each-indexed75492
Ref: !cdr75785 Ref: -dotimes76010
Node: Function combinators75980 Ref: -doto76313
Ref: -partial76254 Node: Destructive operations76740
Ref: -rpartial76649 Ref: !cons76913
Ref: -juxt77051 Ref: !cdr77119
Ref: -compose77483 Node: Function combinators77314
Ref: -applify78041 Ref: -partial77588
Ref: -on78488 Ref: -rpartial77983
Ref: -flip79011 Ref: -juxt78385
Ref: -const79323 Ref: -compose78817
Ref: -cut79667 Ref: -applify79375
Ref: -not80153 Ref: -on79822
Ref: -orfn80463 Ref: -flip80345
Ref: -andfn80897 Ref: -const80657
Ref: -iteratefn81392 Ref: -cut81001
Ref: -fixfn82095 Ref: -not81487
Ref: -prodfn83664 Ref: -orfn81797
Node: Development84730 Ref: -andfn82231
Node: Contribute85079 Ref: -iteratefn82726
Node: Changes85827 Ref: -fixfn83429
Node: Contributors88826 Ref: -prodfn84998
Node: Index90450 Node: Development86064
Node: Contribute86413
Node: Changes87161
Node: Contributors90160
Node: Index91784
 
End Tag Table End Tag Table

@ -298,7 +298,7 @@ See also: @code{-map-when} (@pxref{-map-when}), @code{-replace-last} (@pxref{-re
@defun -map-indexed (fn list) @defun -map-indexed (fn list)
Return a new list consisting of the result of (@var{fn} index item) for each item in @var{list}. Return a new list consisting of the result of (@var{fn} index item) for each item in @var{list}.
In the anaphoric form @code{--map-indexed}, the index is exposed as `it-index`. In the anaphoric form @code{--map-indexed}, the index is exposed as symbol @code{it-index}.
See also: @code{-each-indexed} (@pxref{-each-indexed}). See also: @code{-each-indexed} (@pxref{-each-indexed}).
@ -1070,7 +1070,7 @@ item, etc. If @var{list} contains no items, return @var{initial-value} and
@var{fn} is not called. @var{fn} is not called.
In the anaphoric form @code{--reduce-from}, the accumulated value is In the anaphoric form @code{--reduce-from}, the accumulated value is
exposed as `acc`. exposed as symbol @code{acc}.
See also: @code{-reduce} (@pxref{-reduce}), @code{-reduce-r} (@pxref{-reduce-r}) See also: @code{-reduce} (@pxref{-reduce}), @code{-reduce-r} (@pxref{-reduce-r})
@ -1126,7 +1126,7 @@ reduce return the result of calling @var{fn} with no arguments. If
@var{list} has only 1 item, it is returned and @var{fn} is not called. @var{list} has only 1 item, it is returned and @var{fn} is not called.
In the anaphoric form @code{--reduce}, the accumulated value is In the anaphoric form @code{--reduce}, the accumulated value is
exposed as `acc`. exposed as symbol @code{acc}.
See also: @code{-reduce-from} (@pxref{-reduce-from}), @code{-reduce-r} (@pxref{-reduce-r}) See also: @code{-reduce-from} (@pxref{-reduce-from}), @code{-reduce-r} (@pxref{-reduce-r})
@ -1404,8 +1404,8 @@ Alias: @code{-any-p}, @code{-some?}, @code{-some-p}
@result{} nil @result{} nil
@end group @end group
@group @group
(--any? (= 0 (% it 2)) '(1 2 3)) (-any? 'null '(1 3 5))
@result{} t @result{} nil
@end group @end group
@end example @end example
@end defun @end defun
@ -1840,6 +1840,86 @@ other value (the body).
@end example @end example
@end defun @end defun
@anchor{-partition-after-pred}
@defun -partition-after-pred (pred list)
Partition directly after each time @var{pred} is true on an element of @var{list}.
@example
@group
(-partition-after-pred (function oddp) '())
@result{} '()
@end group
@group
(-partition-after-pred (function oddp) '(1))
@result{} '((1))
@end group
@group
(-partition-after-pred (function oddp) '(0 1))
@result{} '((0 1))
@end group
@end example
@end defun
@anchor{-partition-before-pred}
@defun -partition-before-pred (pred list)
Partition directly before each time @var{pred} is true on an element of @var{list}.
@example
@group
(-partition-before-pred (function oddp) '())
@result{} '()
@end group
@group
(-partition-before-pred (function oddp) '(1))
@result{} '((1))
@end group
@group
(-partition-before-pred (function oddp) '(0 1))
@result{} '((0) (1))
@end group
@end example
@end defun
@anchor{-partition-before-item}
@defun -partition-before-item (item list)
Partition directly before each time @var{item} appears in @var{list}.
@example
@group
(-partition-before-item 3 '())
@result{} '()
@end group
@group
(-partition-before-item 3 '(1))
@result{} '((1))
@end group
@group
(-partition-before-item 3 '(3))
@result{} '((3))
@end group
@end example
@end defun
@anchor{-partition-after-item}
@defun -partition-after-item (item list)
Partition directly after each time @var{item} appears in @var{list}.
@example
@group
(-partition-after-item 3 '())
@result{} '()
@end group
@group
(-partition-after-item 3 '(1))
@result{} '((1))
@end group
@group
(-partition-after-item 3 '(3))
@result{} '((3))
@end group
@end example
@end defun
@anchor{-group-by} @anchor{-group-by}
@defun -group-by (fn list) @defun -group-by (fn list)
Separate @var{list} into an alist whose keys are @var{fn} applied to the Separate @var{list} into an alist whose keys are @var{fn} applied to the
@ -2288,8 +2368,8 @@ function is applied pairwise taking as first argument element of
@var{list1} and as second argument element of @var{list2} at corresponding @var{list1} and as second argument element of @var{list2} at corresponding
position. position.
The anaphoric form @code{--zip-with} binds the elements from @var{list1} as `it`, The anaphoric form @code{--zip-with} binds the elements from @var{list1} as symbol @code{it},
and the elements from @var{list2} as `other`. and the elements from @var{list2} as symbol @code{other}.
@example @example
@group @group
@ -2497,8 +2577,8 @@ Alias: @code{-find}
@result{} nil @result{} nil
@end group @end group
@group @group
(--first (> it 2) '(1 2 3)) (-first 'null '(1 3 5))
@result{} 3 @result{} nil
@end group @end group
@end example @end example
@end defun @end defun
@ -2515,12 +2595,12 @@ Alias: @code{-any}
@result{} t @result{} t
@end group @end group
@group @group
(--some (member 'foo it) '((foo bar) (baz))) (-some 'null '(1 2 3))
@result{} '(foo bar) @result{} nil
@end group @end group
@group @group
(--some (plist-get it :bar) '((:foo 1 :bar 2) (:baz 3))) (-some 'null '(1 2 nil))
@result{} 2 @result{} t
@end group @end group
@end example @end example
@end defun @end defun
@ -2925,7 +3005,7 @@ last item in second form, etc.
@defmac --> (x &rest forms) @defmac --> (x &rest forms)
Starting with the value of @var{x}, thread each expression through @var{forms}. Starting with the value of @var{x}, thread each expression through @var{forms}.
Insert @var{x} at the position signified by the token @code{it} in the first Insert @var{x} at the position signified by the symbol @code{it} in the first
form. If there are more forms, insert the first form at the position form. If there are more forms, insert the first form at the position
signified by @code{it} in in second form, etc. signified by @code{it} in in second form, etc.
@ -3042,10 +3122,11 @@ Convenient versions of `let` and `let*` constructs combined with flow control.
@anchor{-when-let} @anchor{-when-let}
@defmac -when-let (var-val &rest body) @defmac -when-let (var-val &rest body)
If @var{val} evaluates to non-nil, bind it to @var{var} and execute body. If @var{val} evaluates to non-nil, bind it to @var{var} and execute body.
@var{var-val} should be a (@var{var} @var{val}) pair.
Note: binding is done according to @code{-let} (@pxref{-let}). Note: binding is done according to @code{-let} (@pxref{-let}).
(fn (@var{var} @var{val}) &rest @var{body})
@example @example
@group @group
(-when-let (match-index (string-match "d" "abcd")) (+ match-index 2)) (-when-let (match-index (string-match "d" "abcd")) (+ match-index 2))
@ -3087,10 +3168,12 @@ encountered.
@anchor{-if-let} @anchor{-if-let}
@defmac -if-let (var-val then &rest else) @defmac -if-let (var-val then &rest else)
If @var{val} evaluates to non-nil, bind it to @var{var} and do @var{then}, If @var{val} evaluates to non-nil, bind it to @var{var} and do @var{then},
otherwise do @var{else}. @var{var-val} should be a (@var{var} @var{val}) pair. otherwise do @var{else}.
Note: binding is done according to @code{-let} (@pxref{-let}). Note: binding is done according to @code{-let} (@pxref{-let}).
(fn (@var{var} @var{val}) @var{then} &rest @var{else})
@example @example
@group @group
(-if-let (match-index (string-match "d" "abc")) (+ match-index 3) 7) (-if-let (match-index (string-match "d" "abc")) (+ match-index 3) 7)
@ -3386,7 +3469,7 @@ Return nil, used for side-effects only.
@defun -each-indexed (list fn) @defun -each-indexed (list fn)
Call (@var{fn} index item) for each item in @var{list}. Call (@var{fn} index item) for each item in @var{list}.
In the anaphoric form @code{--each-indexed}, the index is exposed as `it-index`. In the anaphoric form @code{--each-indexed}, the index is exposed as symbol @code{it-index}.
See also: @code{-map-indexed} (@pxref{-map-indexed}). See also: @code{-map-indexed} (@pxref{-map-indexed}).

@ -384,6 +384,8 @@ new list."
(defexamples -any? (defexamples -any?
(-any? 'even? '(1 2 3)) => t (-any? 'even? '(1 2 3)) => t
(-any? 'even? '(1 3 5)) => nil (-any? 'even? '(1 3 5)) => nil
(-any? 'null '(1 3 5)) => nil
(-any? 'null '(1 3 ())) => t
(--any? (= 0 (% it 2)) '(1 2 3)) => t) (--any? (= 0 (% it 2)) '(1 2 3)) => t)
(defexamples -all? (defexamples -all?
@ -698,10 +700,14 @@ new list."
(defexamples -first (defexamples -first
(-first 'even? '(1 2 3)) => 2 (-first 'even? '(1 2 3)) => 2
(-first 'even? '(1 3 5)) => nil (-first 'even? '(1 3 5)) => nil
(-first 'null '(1 3 5)) => nil
(-first 'null '(1 3 ())) => nil
(--first (> it 2) '(1 2 3)) => 3) (--first (> it 2) '(1 2 3)) => 3)
(defexamples -some (defexamples -some
(-some 'even? '(1 2 3)) => t (-some 'even? '(1 2 3)) => t
(-some 'null '(1 2 3)) => nil
(-some 'null '(1 2 ())) => t
(--some (member 'foo it) '((foo bar) (baz))) => '(foo bar) (--some (member 'foo it) '((foo bar) (baz))) => '(foo bar)
(--some (plist-get it :bar) '((:foo 1 :bar 2) (:baz 3))) => 2) (--some (plist-get it :bar) '((:foo 1 :bar 2) (:baz 3))) => 2)

Loading…
Cancel
Save