diff --git a/README.md b/README.md index c7b6068..d4431e4 100644 --- a/README.md +++ b/README.md @@ -715,8 +715,9 @@ element `elem`, in ascending order. #### -find-index `(pred list)` -Return the indices of all elements in `list` satisfying the -predicate `pred`, in ascending order. +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. ```cl (-find-index 'even? '(2 4 1 6 3 3 5 8)) ;; => 0 @@ -726,9 +727,8 @@ predicate `pred`, in ascending order. #### -find-indices `(pred list)` -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. +Return the indices of all elements in `list` satisfying the +predicate `pred`, in ascending order. ```cl (-find-indices 'even? '(2 4 1 6 3 3 5 8)) ;; => '(0 1 3 7) diff --git a/dash.el b/dash.el index 9e803c6..9e6edd8 100644 --- a/dash.el +++ b/dash.el @@ -709,9 +709,8 @@ element ELEM, in ascending order." (-find-indices (-partial 'equal elem) list)) (defun -find-indices (pred list) - "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." + "Return the indices of all elements in LIST satisfying the +predicate PRED, in ascending order." (let ((i 0)) (apply 'append (--map-indexed (when (funcall pred it) (list it-index)) list)))) @@ -720,8 +719,9 @@ there is no such element." `(-find-indices (lambda (it) ,form) ,list)) (defun -find-index (pred list) - "Return the indices of all elements in LIST satisfying the -predicate PRED, in ascending order." + "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." (car (-find-indices pred list))) (defmacro --find-index (form list)