@ -858,14 +858,16 @@ This is the anaphoric counterpart to `-first'."
( defun -first ( pred list )
( defun -first ( pred list )
" Return the first item in LIST for which PRED returns non-nil.
" Return the first item in LIST for which PRED returns non-nil.
Return nil if no such element is found.
Return nil if no such element is found.
To get the first item in the list no questions asked, use ` car '.
To get the first item in the list no questions asked,
use ` -first-item '.
Alias: ` -find '.
Alias: ` -find '.
This function 's anaphoric counterpart is ` --first '. "
This function 's anaphoric counterpart is ` --first '. "
( --first ( funcall pred it ) list ) )
( --first ( funcall pred it ) list ) )
( defalias '-find ' -first)
( defalias '-find #' -first )
( defalias '--find '--first )
( defalias '--find '--first )
( defmacro --some ( form list )
( defmacro --some ( form list )
@ -1780,54 +1782,88 @@ See also: `-flatten-n', `-table'"
( dash--table-carry lists restore-lists ) ) )
( dash--table-carry lists restore-lists ) ) )
( nreverse re ) ) )
( nreverse re ) ) )
( defmacro --find-index ( form list )
" Return the first index in LIST for which FORM evals to non-nil.
Return nil if no such index is found.
Each element of LIST in turn is bound to ` it ' and its index
within LIST to ` it-index ' before evaluating FORM.
This is the anaphoric counterpart to ` -find-index '. "
( declare ( debug ( form form ) ) )
` ( --some ( and , form it-index ) , list ) )
( defun -find-index ( pred list )
" Return the index of the first item satisfying PRED in LIST.
Return nil if no such item is found.
PRED is called with one argument, the current list element, until
it returns non-nil, at which point the search terminates.
This function 's anaphoric counterpart is ` --find-index '.
See also: ` -first ', ` -find-last-index '. "
( --find-index ( funcall pred it ) list ) )
( defun -elem-index ( elem list )
( defun -elem-index ( elem list )
" Return the index of the first element in the given LIST which
" Return the first index of ELEM in LIST.
is equal to the query element ELEM, or nil if there is no
That is, the index within LIST of the first element that is
such element. "
` equal ' to ELEM. Return nil if there is no such element.
( declare ( pure t ) ( side-effect-free t ) )
( car ( -elem-indices elem list ) ) )
( defun -elem-indices ( elem list )
See also: ` -find-index '. "
" Return the indices of all elements in LIST equal to the query
element ELEM, in ascending order. "
( declare ( pure t ) ( side-effect-free t ) )
( declare ( pure t ) ( side-effect-free t ) )
( -find-indices ( -partial 'equal elem ) list ) )
( --find-index ( equal elem it ) list ) )
( defmacro --find-indices ( form list )
" Return the list of indices in LIST for which FORM evals to non-nil.
Each element of LIST in turn is bound to ` it ' and its index
within LIST to ` it-index ' before evaluating FORM.
This is the anaphoric counterpart to ` -find-indices '. "
( declare ( debug ( form form ) ) )
` ( --keep ( and , form it-index ) , list ) )
( defun -find-indices ( pred list )
( defun -find-indices ( pred list )
" Return the indices of all elements in LIST satisfying the
" Return the list of indices in LIST satisfying PRED.
predicate PRED, in ascending order. "
( apply 'append ( --map-indexed ( when ( funcall pred it ) ( list it-index ) ) list ) ) )
( defmacro --find-indices ( form list )
Each element of LIST in turn is passed to PRED. If the result is
" Anaphoric version of `-find-indices' . "
non-nil, the index of that element in LIST is included in the
( declare ( debug ( def-form form ) ) )
result. The returned indices are in ascending order, i.e., in
` ( -find-indices ( lambda ( it ) ( ignore it ) , form ) , list ) )
the same order as they appear in LIST.
( defun -find-index ( pred list )
This function 's anaphoric counterpart is ` --find-indices '.
" Take a predicate PRED and a LIST and return the index of the
first element in the list satisfying the predicate, or nil if
there is no such element.
See also ` -first '. "
See also: ` -find-index ', ` -elem-indices '. "
( car ( -find-indices pred list ) ) )
( --find-indices ( funcall pred it ) list ) )
( defmacro --find-index ( form list )
( defun -elem-indices ( elem list )
" Anaphoric version of `-find-index' . "
" Return the list of indices at which ELEM appears in LIST.
( declare ( debug ( def-form form ) ) )
That is, the indices of all elements of LIST ` equal ' to ELEM, in
` ( -find-index ( lambda ( it ) ( ignore it ) , form ) , list ) )
the same ascending order as they appear in LIST. "
( declare ( pure t ) ( side-effect-free t ) )
( --find-indices ( equal elem it ) list ) )
( defmacro --find-last-index ( form list )
" Return the last index in LIST for which FORM evals to non-nil.
Return nil if no such index is found.
Each element of LIST in turn is bound to ` it ' and its index
within LIST to ` it-index ' before evaluating FORM.
This is the anaphoric counterpart to ` -find-last-index '. "
( declare ( debug ( form form ) ) )
( let ( ( i ( make-symbol " index " ) ) )
` ( let ( , i )
( --each , list
( when , form ( setq , i it-index ) ) )
, i ) ) )
( defun -find-last-index ( pred list )
( defun -find-last-index ( pred list )
" Take a predicate PRED and a LIST and return the index of the
" Return the index of the last item satisfying PRED in LIST.
last element in the list satisfying the predicate, or nil if
Return nil if no such item is found.
there is no such element.
See also ` -last '. "
Predicate PRED is called with one argument each time, namely the
( -last-item ( -find-indices pred list ) ) )
current list element.
( defmacro --find-last-index ( form list )
This function 's anaphoric counterpart is ` --find-last-index '.
" Anaphoric version of `-find-last-index' . "
( declare ( debug ( def-form form ) ) )
See also: ` -last ', ` -find-index '. "
` ( -find-last-index ( lambda ( it ) ( ignore it ) , form ) , list ) )
( - -find-last-index ( funcall pred it ) list ) )
( defun -select-by-indices ( indices list )
( defun -select-by-indices ( indices list )
" Return a list whose elements are elements from LIST selected
" Return a list whose elements are elements from LIST selected