Upgrade dash

This commit is contained in:
Daniel - 2021-09-04 14:47:04 +02:00
parent e37be56b64
commit 0c28ac9283
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
5 changed files with 482 additions and 298 deletions

View File

@ -1,6 +1,6 @@
(define-package "dash" "20210609.1330" "A modern list library for Emacs"
(define-package "dash" "20210826.1149" "A modern list library for Emacs"
'((emacs "24"))
:commit "88d799595e8f1b4154637ce8a3f81b97b0520c1a" :authors
:commit "39d067b9fbb2db65fc7a6938bfb21489ad990cb4" :authors
'(("Magnar Sveen" . "magnars@gmail.com"))
:maintainer
'("Magnar Sveen" . "magnars@gmail.com")

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2012-2021 Free Software Foundation, Inc.
;; Author: Magnar Sveen <magnars@gmail.com>
;; Version: 2.18.1
;; Version: 2.19.1
;; Package-Requires: ((emacs "24"))
;; Keywords: extensions, lisp
;; Homepage: https://github.com/magnars/dash.el
@ -854,6 +854,36 @@ This function's anaphoric counterpart is `--some'."
(defalias '-any '-some)
(defalias '--any '--some)
(defmacro --every (form list)
"Return non-nil if FORM evals to non-nil for all items in LIST.
If so, return the last such result of FORM. Otherwise, once an
item is reached for which FORM yields nil, return nil without
evaluating FORM for any further LIST elements.
Each element of LIST in turn is bound to `it' and its index
within LIST to `it-index' before evaluating FORM.
This macro is like `--every-p', but on success returns the last
non-nil result of FORM instead of just t.
This is the anaphoric counterpart to `-every'."
(declare (debug (form form)))
(let ((a (make-symbol "all")))
`(let ((,a t))
(--each-while ,list (setq ,a ,form))
,a)))
(defun -every (pred list)
"Return non-nil if PRED returns non-nil for all items in LIST.
If so, return the last such result of PRED. Otherwise, once an
item is reached for which PRED returns nil, return nil without
calling PRED on any further LIST elements.
This function is like `-every-p', but on success returns the last
non-nil result of PRED instead of just t.
This function's anaphoric counterpart is `--every'."
(--every (funcall pred it) list))
(defmacro --last (form list)
"Anaphoric form of `-last'."
(declare (debug (form form)))
@ -949,7 +979,7 @@ See also: `-last-item'."
(defmacro --any? (form list)
"Anaphoric form of `-any?'."
(declare (debug (form form)))
`(---truthy? (--some ,form ,list)))
`(and (--some ,form ,list) t))
(defun -any? (pred list)
"Return t if (PRED x) is non-nil for any x in LIST, else nil.
@ -965,17 +995,34 @@ Alias: `-any-p', `-some?', `-some-p'"
(defalias '--some-p '--any?)
(defmacro --all? (form list)
"Anaphoric form of `-all?'."
"Return t if FORM evals to non-nil for all items in LIST.
Otherwise, once an item is reached for which FORM yields nil,
return nil without evaluating FORM for any further LIST elements.
Each element of LIST in turn is bound to `it' and its index
within LIST to `it-index' before evaluating FORM.
The similar macro `--every' is more widely useful, since it
returns the last non-nil result of FORM instead of just t on
success.
Alias: `--all-p', `--every-p', `--every?'.
This is the anaphoric counterpart to `-all?'."
(declare (debug (form form)))
(let ((a (make-symbol "all")))
`(let ((,a t))
(--each-while ,list ,a (setq ,a ,form))
(---truthy? ,a))))
`(and (--every ,form ,list) t))
(defun -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.
In the latter case, stop after the first X for which (PRED X) is
nil, without calling PRED on any subsequent elements of LIST.
Alias: `-all-p', `-every?', `-every-p'"
The similar function `-every' is more widely useful, since it
returns the last non-nil result of PRED instead of just t on
success.
Alias: `-all-p', `-every-p', `-every?'.
This function's anaphoric counterpart is `--all?'."
(--all? (funcall pred it) list))
(defalias '-every? '-all?)
@ -1143,14 +1190,15 @@ is done in a single list traversal."
(list (nreverse result) list)))
(defun -rotate (n list)
"Rotate LIST N places to the right. With N negative, rotate to the left.
"Rotate LIST N places to the right (left if N is negative).
The time complexity is O(n)."
(declare (pure t) (side-effect-free t))
(when list
(let* ((len (length list))
(n-mod-len (mod n len))
(new-tail-len (- len n-mod-len)))
(append (nthcdr new-tail-len list) (-take new-tail-len list)))))
(cond ((null list) ())
((zerop n) (copy-sequence list))
((let* ((len (length list))
(n-mod-len (mod n len))
(new-tail-len (- len n-mod-len)))
(append (nthcdr new-tail-len list) (-take new-tail-len list))))))
(defun -insert-at (n x list)
"Return a list with X inserted into LIST at position N.
@ -1747,8 +1795,7 @@ See also: `-select-columns', `-select-by-indices'"
in the first form, making a list of it if it is not a list
already. If there are more forms, insert the first form as the
second item in second form, etc."
(declare (debug (form &rest [&or symbolp (sexp &rest form)]))
(indent 1))
(declare (debug (form &rest [&or symbolp (sexp &rest form)])))
(cond
((null form) x)
((null more) (if (listp form)
@ -1761,8 +1808,7 @@ second item in second form, etc."
in the first form, making a list of it if it is not a list
already. If there are more forms, insert the first form as the
last item in second form, etc."
(declare (debug ->)
(indent 1))
(declare (debug ->))
(cond
((null form) x)
((null more) (if (listp form)
@ -1776,7 +1822,7 @@ last item in second form, etc."
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
signified by `it' in in second form, etc."
(declare (debug (form body)) (indent 1))
(declare (debug (form body)))
`(-as-> ,x it ,@forms))
(defmacro -as-> (value variable &rest forms)
@ -1789,9 +1835,9 @@ VARIABLE to the result of the first form, and so forth."
`,value
`(let ((,variable ,value))
(-as-> ,(if (symbolp (car forms))
(list (car forms) variable)
(car forms))
,variable
(list (car forms) variable)
(car forms))
,variable
,@(cdr forms)))))
(defmacro -some-> (x &optional form &rest more)
@ -1803,7 +1849,7 @@ and when that result is non-nil, through the next form, etc."
(let ((result (make-symbol "result")))
`(-some-> (-when-let (,result ,x)
(-> ,result ,form))
,@more))))
,@more))))
(defmacro -some->> (x &optional form &rest more)
"When expr is non-nil, thread it through the first form (via `->>'),
@ -1814,7 +1860,7 @@ and when that result is non-nil, through the next form, etc."
(let ((result (make-symbol "result")))
`(-some->> (-when-let (,result ,x)
(->> ,result ,form))
,@more))))
,@more))))
(defmacro -some--> (expr &rest forms)
"Thread EXPR through FORMS via `-->', while the result is non-nil.
@ -2683,9 +2729,7 @@ Alias: `-is-prefix-p'."
Alias: `-is-suffix-p'."
(declare (pure t) (side-effect-free t))
(cond ((null suffix))
((setq list (member (car suffix) list))
(equal (cdr suffix) (cdr list)))))
(equal suffix (last list (length suffix))))
(defun -is-infix? (infix list)
"Return non-nil if INFIX is infix of LIST.
@ -3067,24 +3111,73 @@ taking 1 argument which is a list of N arguments."
(declare (pure t) (side-effect-free t))
(lambda (args) (apply fn args)))
(defun -on (operator transformer)
"Return a function of two arguments that first applies
TRANSFORMER to each of them and then applies OPERATOR on the
results (in the same order).
(defun -on (op trans)
"Return a function that calls TRANS on each arg and OP on the results.
The returned function takes a variable number of arguments, calls
the function TRANS on each one in turn, and then passes those
results as the list of arguments to OP, in the same order.
In types: (b -> b -> c) -> (a -> b) -> a -> a -> c"
(lambda (x y) (funcall operator (funcall transformer x) (funcall transformer y))))
For example, the following pairs of expressions are morally
equivalent:
(defun -flip (func)
"Swap the order of arguments for binary function FUNC.
(funcall (-on #\\='+ #\\='1+) 1 2 3) = (+ (1+ 1) (1+ 2) (1+ 3))
(funcall (-on #\\='+ #\\='1+)) = (+)"
(declare (pure t) (side-effect-free t))
(lambda (&rest args)
;; This unrolling seems to be a relatively cheap way to keep the
;; overhead of `mapcar' + `apply' in check.
(cond ((cddr args)
(apply op (mapcar trans args)))
((cdr args)
(funcall op (funcall trans (car args)) (funcall trans (cadr args))))
(args
(funcall op (funcall trans (car args))))
((funcall op)))))
In types: (a -> b -> c) -> b -> a -> c"
(lambda (x y) (funcall func y x)))
(defun -flip (fn)
"Return a function that calls FN with its arguments reversed.
The returned function takes the same number of arguments as FN.
For example, the following two expressions are morally
equivalent:
(funcall (-flip #\\='-) 1 2) = (- 2 1)
See also: `-rotate-args'."
(declare (pure t) (side-effect-free t))
(lambda (&rest args) ;; Open-code for speed.
(cond ((cddr args) (apply fn (nreverse args)))
((cdr args) (funcall fn (cadr args) (car args)))
(args (funcall fn (car args)))
((funcall fn)))))
(defun -rotate-args (n fn)
"Return a function that calls FN with args rotated N places to the right.
The returned function takes the same number of arguments as FN,
rotates the list of arguments N places to the right (left if N is
negative) just like `-rotate', and applies FN to the result.
See also: `-flip'."
(declare (pure t) (side-effect-free t))
(if (zerop n)
fn
(let ((even (= (% n 2) 0)))
(lambda (&rest args)
(cond ((cddr args) ;; Open-code for speed.
(apply fn (-rotate n args)))
((cdr args)
(let ((fst (car args))
(snd (cadr args)))
(funcall fn (if even fst snd) (if even snd fst))))
(args
(funcall fn (car args)))
((funcall fn)))))))
(defun -const (c)
"Return a function that returns C ignoring any additional arguments.
In types: a -> b -> a"
(declare (pure t) (side-effect-free t))
(lambda (&rest _) c))
(defmacro -cut (&rest params)
@ -3101,30 +3194,51 @@ See SRFI-26 for detailed description."
`(lambda ,args
,(let ((body (--map (if (eq it '<>) (pop args) it) params)))
(if (eq (car params) '<>)
(cons 'funcall body)
(cons #'funcall body)
body)))))
(defun -not (pred)
"Take a unary predicate PRED and return a unary predicate
that returns t if PRED returns nil and nil if PRED returns
non-nil."
(lambda (x) (not (funcall pred x))))
"Return a predicate that negates the result of PRED.
The returned predicate passes its arguments to PRED. If PRED
returns nil, the result is non-nil; otherwise the result is nil.
See also: `-andfn' and `-orfn'."
(declare (pure t) (side-effect-free t))
(lambda (&rest args) (not (apply pred args))))
(defun -orfn (&rest preds)
"Take list of unary predicates PREDS and return a unary
predicate with argument x that returns non-nil if at least one of
the PREDS returns non-nil on x.
"Return a predicate that returns the first non-nil result of PREDS.
The returned predicate takes a variable number of arguments,
passes them to each predicate in PREDS in turn until one of them
returns non-nil, and returns that non-nil result without calling
the remaining PREDS. If all PREDS return nil, or if no PREDS are
given, the returned predicate returns nil.
In types: [a -> Bool] -> a -> Bool"
(lambda (x) (-any? (-cut funcall <> x) preds)))
See also: `-andfn' and `-not'."
(declare (pure t) (side-effect-free t))
;; Open-code for speed.
(cond ((cdr preds) (lambda (&rest args) (--some (apply it args) preds)))
(preds (car preds))
(#'ignore)))
(defun -andfn (&rest preds)
"Take list of unary predicates PREDS and return a unary
predicate with argument x that returns non-nil if all of the
PREDS returns non-nil on x.
"Return a predicate that returns non-nil if all PREDS do so.
The returned predicate P takes a variable number of arguments and
passes them to each predicate in PREDS in turn. If any one of
PREDS returns nil, P also returns nil without calling the
remaining PREDS. If all PREDS return non-nil, P returns the last
such value. If no PREDS are given, P always returns non-nil.
In types: [a -> Bool] -> a -> Bool"
(lambda (x) (-all? (-cut funcall <> x) preds)))
See also: `-orfn' and `-not'."
(declare (pure t) (side-effect-free t))
;; Open-code for speed.
(cond ((cdr preds) (lambda (&rest args) (--every (apply it args) preds)))
(preds (car preds))
;; As a `pure' function, this runtime check may generate
;; backward-incompatible bytecode for `(-andfn)' at compile-time,
;; but I doubt that's a problem in practice (famous last words).
((fboundp 'always) #'always)
((lambda (&rest _) t))))
(defun -iteratefn (fn n)
"Return a function FN composed N times with itself.
@ -3188,18 +3302,18 @@ cdr the final output from HALT-TEST.
In types: (a -> a) -> a -> a."
(let ((eqfn (or equal-test 'equal))
(haltfn (or halt-test
(-not
(-counter 0 -fixfn-max-iterations)))))
(haltfn (or halt-test
(-not
(-counter 0 -fixfn-max-iterations)))))
(lambda (x)
(let ((re (funcall fn x))
(halt? (funcall haltfn x)))
(while (and (not halt?) (not (funcall eqfn x re)))
(setq x re
re (funcall fn re)
halt? (funcall haltfn re)))
(if halt? (cons 'halted halt?)
re)))))
(halt? (funcall haltfn x)))
(while (and (not halt?) (not (funcall eqfn x re)))
(setq x re
re (funcall fn re)
halt? (funcall haltfn re)))
(if halt? (cons 'halted halt?)
re)))))
(defun -prodfn (&rest fns)
"Take a list of n functions and return a function that takes a

View File

@ -1,6 +1,6 @@
This is dash.info, produced by makeinfo version 6.7 from dash.texi.
This manual is for Dash version 2.18.1.
This manual is for Dash version 2.19.1.
Copyright © 20122021 Free Software Foundation, Inc.
@ -22,7 +22,7 @@ File: dash.info, Node: Top, Next: Installation, Up: (dir)
Dash
****
This manual is for Dash version 2.18.1.
This manual is for Dash version 2.19.1.
Copyright © 20122021 Free Software Foundation, Inc.
@ -110,7 +110,7 @@ File: dash.info, Node: Using in a package, Next: Fontification of special vari
If you use Dash in your own package, be sure to list it as a dependency
in the librarys headers as follows (*note (elisp)Library Headers::).
;; Package-Requires: ((dash "2.18.1"))
;; Package-Requires: ((dash "2.19.1"))

File: dash.info, Node: Fontification of special variables, Next: Info symbol lookup, Prev: Using in a package, Up: Installation
@ -1135,27 +1135,68 @@ File: dash.info, Node: Predicates, Next: Partitioning, Prev: Unfolding, Up:
Reductions of one or more lists to a boolean value.
-- Function: -some (pred list)
Return (PRED x) for the first LIST item where (PRED x) is non-nil,
else nil.
Alias: -any.
This functions anaphoric counterpart is --some.
(-some #'stringp '(1 "2" 3))
⇒ t
(--some (string-match-p "x" it) '("foo" "axe" "xor"))
⇒ 1
(--some (= it-index 3) '(0 1 2))
⇒ nil
-- Function: -every (pred list)
Return non-nil if PRED returns non-nil for all items in LIST. If
so, return the last such result of PRED. Otherwise, once an item
is reached for which PRED returns nil, return nil without calling
PRED on any further LIST elements.
This function is like -every-p, but on success returns the last
non-nil result of PRED instead of just t.
This functions anaphoric counterpart is --every.
(-every #'numberp '(1 2 3))
⇒ t
(--every (string-match-p "x" it) '("axe" "xor"))
⇒ 0
(--every (= it it-index) '(0 1 3))
⇒ nil
-- Function: -any? (pred list)
Return t if (PRED x) is non-nil for any x in LIST, else nil.
Alias: -any-p, -some?, -some-p
(-any? 'even? '(1 2 3))
(-any? #'numberp '(nil 0 t))
⇒ t
(-any? 'even? '(1 3 5))
(-any? #'numberp '(nil t t))
⇒ nil
(-any? 'null '(1 3 5))
(-any? #'null '(1 3 5))
⇒ nil
-- 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. In
the latter case, stop after the first X for which (PRED X) is nil,
without calling PRED on any subsequent elements of LIST.
Alias: -all-p, -every?, -every-p
The similar function -every (*note -every::) is more widely
useful, since it returns the last non-nil result of PRED instead of
just t on success.
(-all? 'even? '(1 2 3))
⇒ nil
(-all? 'even? '(2 4 6))
Alias: -all-p, -every-p, -every?.
This functions anaphoric counterpart is --all?.
(-all? #'numberp '(1 2 3))
⇒ t
(-all? #'numberp '(2 t 6))
⇒ nil
(--all? (= 0 (% it 2)) '(2 4 6))
⇒ t
@ -1313,9 +1354,9 @@ Functions partitioning the input list into a list of lists.
(-split-on '| '(Nil | Leaf a | Node [Tree a]))
⇒ ((Nil) (Leaf a) (Node [Tree a]))
(-split-on ':endgroup '("a" "b" :endgroup "c" :endgroup "d" "e"))
(-split-on :endgroup '("a" "b" :endgroup "c" :endgroup "d" "e"))
⇒ (("a" "b") ("c") ("d" "e"))
(-split-on ':endgroup '("a" "b" :endgroup :endgroup "d" "e"))
(-split-on :endgroup '("a" "b" :endgroup :endgroup "d" "e"))
⇒ (("a" "b") ("d" "e"))
-- Function: -split-when (fn list)
@ -1647,8 +1688,8 @@ File: dash.info, Node: Other list operations, Next: Tree operations, Prev: Se
Other list functions not fit to be classified elsewhere.
-- Function: -rotate (n list)
Rotate LIST N places to the right. With N negative, rotate to the
left. The time complexity is O(n).
Rotate LIST N places to the right (left if N is negative). The
time complexity is O(n).
(-rotate 3 '(1 2 3 4 5 6 7))
⇒ (5 6 7 1 2 3 4)
@ -1900,21 +1941,6 @@ Other list functions not fit to be classified elsewhere.
(--first (> it 2) '(1 2 3))
⇒ 3
-- Function: -some (pred list)
Return (PRED x) for the first LIST item where (PRED x) is non-nil,
else nil.
Alias: -any.
This functions anaphoric counterpart is --some.
(-some (lambda (s) (string-match-p "x" s)) '("foo" "axe" "xor"))
⇒ 1
(-some (lambda (s) (string-match-p "x" s)) '("foo" "bar" "baz"))
⇒ nil
(--some (member 'foo it) '((foo bar) (baz)))
⇒ (foo bar)
-- Function: -last (pred list)
Return the last x in LIST where (PRED x) is non-nil, else nil.
@ -2768,31 +2794,58 @@ Functions that manipulate and compose other functions.
(funcall (-applify #'<) '(3 6))
⇒ t
-- Function: -on (operator transformer)
Return a function of two arguments that first applies TRANSFORMER
to each of them and then applies OPERATOR on the results (in the
same order).
-- Function: -on (op trans)
Return a function that calls TRANS on each arg and OP on the
results. The returned function takes a variable number of
arguments, calls the function TRANS on each one in turn, and then
passes those results as the list of arguments to OP, in the same
order.
In types: (b -> b -> c) -> (a -> b) -> a -> a -> c
For example, the following pairs of expressions are morally
equivalent:
(-sort (-on '< 'length) '((1 2 3) (1) (1 2)))
(funcall (-on #+ #1+) 1 2 3) = (+ (1+ 1) (1+ 2) (1+ 3)) (funcall
(-on #+ #1+)) = (+)
(-sort (-on #'< #'length) '((1 2 3) (1) (1 2)))
⇒ ((1) (1 2) (1 2 3))
(-min-by (-on '> 'length) '((1 2 3) (4) (1 2)))
(funcall (-on #'min #'string-to-number) "22" "2" "1" "12")
⇒ 1
(-min-by (-on #'> #'length) '((1 2 3) (4) (1 2)))
⇒ (4)
(-min-by (-on 'string-lessp 'number-to-string) '(2 100 22))
⇒ 22
-- Function: -flip (func)
Swap the order of arguments for binary function FUNC.
-- Function: -flip (fn)
Return a function that calls FN with its arguments reversed. The
returned function takes the same number of arguments as FN.
In types: (a -> b -> c) -> b -> a -> c
For example, the following two expressions are morally equivalent:
(funcall (-flip '<) 2 1)
⇒ t
(funcall (-flip '-) 3 8)
⇒ 5
(-sort (-flip '<) '(4 3 6 1))
(funcall (-flip #-) 1 2) = (- 2 1)
See also: -rotate-args (*note -rotate-args::).
(-sort (-flip #'<) '(4 3 6 1))
⇒ (6 4 3 1)
(funcall (-flip #'-) 3 2 1 10)
⇒ 4
(funcall (-flip #'1+) 1)
⇒ 2
-- Function: -rotate-args (n fn)
Return a function that calls FN with args rotated N places to the
right. The returned function takes the same number of arguments as
FN, rotates the list of arguments N places to the right (left if N
is negative) just like -rotate (*note -rotate::), and applies FN
to the result.
See also: -flip (*note -flip::).
(funcall (-rotate-args -1 #'list) 1 2 3 4)
⇒ (2 3 4 1)
(funcall (-rotate-args 1 #'-) 1 10 100)
⇒ 89
(funcall (-rotate-args 2 #'list) 3 4 5 1 2)
⇒ (1 2 3 4 5)
-- Function: -const (c)
Return a function that returns C ignoring any additional arguments.
@ -2801,9 +2854,9 @@ Functions that manipulate and compose other functions.
(funcall (-const 2) 1 3 "foo")
⇒ 2
(-map (-const 1) '("a" "b" "c" "d"))
(mapcar (-const 1) '("a" "b" "c" "d"))
⇒ (1 1 1 1)
(-sum (-map (-const 1) '("a" "b" "c" "d")))
(-sum (mapcar (-const 1) '("a" "b" "c" "d")))
⇒ 4
-- Macro: -cut (&rest params)
@ -2820,39 +2873,52 @@ Functions that manipulate and compose other functions.
⇒ ((1 2 3) [1 2 3] "\1\2\3")
-- Function: -not (pred)
Take a unary predicate PRED and return a unary predicate that
returns t if PRED returns nil and nil if PRED returns non-nil.
Return a predicate that negates the result of PRED. The returned
predicate passes its arguments to PRED. If PRED returns nil, the
result is non-nil; otherwise the result is nil.
(funcall (-not 'even?) 5)
See also: -andfn (*note -andfn::) and -orfn (*note -orfn::).
(funcall (-not #'numberp) "5")
⇒ t
(-filter (-not (-partial '< 4)) '(1 2 3 4 5 6 7 8))
(-sort (-not #'<) '(5 2 1 0 6))
⇒ (6 5 2 1 0)
(-filter (-not (-partial #'< 4)) '(1 2 3 4 5 6 7 8))
⇒ (1 2 3 4)
-- Function: -orfn (&rest preds)
Take list of unary predicates PREDS and return a unary predicate
with argument x that returns non-nil if at least one of the PREDS
returns non-nil on x.
Return a predicate that returns the first non-nil result of PREDS.
The returned predicate takes a variable number of arguments, passes
them to each predicate in PREDS in turn until one of them returns
non-nil, and returns that non-nil result without calling the
remaining PREDS. If all PREDS return nil, or if no PREDS are
given, the returned predicate returns nil.
In types: [a -> Bool] -> a -> Bool
See also: -andfn (*note -andfn::) and -not (*note -not::).
(-filter (-orfn 'even? (-partial (-flip '<) 5)) '(1 2 3 4 5 6 7 8 9 10))
⇒ (1 2 3 4 6 8 10)
(funcall (-orfn 'stringp 'even?) "foo")
(-filter (-orfn #'natnump #'booleanp) '(1 nil "a" -4 b c t))
⇒ (1 nil t)
(funcall (-orfn #'symbolp (-cut string-match-p "x" <>)) "axe")
⇒ 1
(funcall (-orfn #'= #'+) 1 1)
⇒ t
-- Function: -andfn (&rest preds)
Take list of unary predicates PREDS and return a unary predicate
with argument x that returns non-nil if all of the PREDS returns
non-nil on x.
Return a predicate that returns non-nil if all PREDS do so. The
returned predicate P takes a variable number of arguments and
passes them to each predicate in PREDS in turn. If any one of
PREDS returns nil, P also returns nil without calling the remaining
PREDS. If all PREDS return non-nil, P returns the last such value.
If no PREDS are given, P always returns non-nil.
In types: [a -> Bool] -> a -> Bool
See also: -orfn (*note -orfn::) and -not (*note -not::).
(funcall (-andfn (-cut < <> 10) 'even?) 6)
t
(funcall (-andfn (-cut < <> 10) 'even?) 12)
⇒ nil
(-filter (-andfn (-not 'even?) (-cut >= 5 <>)) '(1 2 3 4 5 6 7 8 9 10))
(1 3 5)
(-filter (-andfn #'numberp (-cut < <> 5)) '(a 1 b 6 c 2))
(1 2)
(mapcar (-andfn #'numberp #'1+) '(a 1 b 6))
(nil 2 nil 7)
(funcall (-andfn #'= #'+) 1 1)
2
-- Function: -iteratefn (fn n)
Return a function FN composed N times with itself.
@ -4231,16 +4297,16 @@ Index
* -->: Threading macros. (line 35)
* ->: Threading macros. (line 9)
* ->>: Threading macros. (line 22)
* -all?: Predicates. (line 20)
* -all?: Predicates. (line 53)
* -andfn: Function combinators.
(line 147)
(line 184)
* -annotate: Maps. (line 84)
* -any?: Predicates. (line 8)
* -any?: Predicates. (line 41)
* -applify: Function combinators.
(line 63)
* -as->: Threading macros. (line 49)
* -butlast: Other list operations.
(line 350)
(line 335)
* -clone: Tree operations. (line 122)
* -common-prefix: Reductions. (line 242)
* -common-suffix: Reductions. (line 252)
@ -4249,14 +4315,14 @@ Index
* -concat: List to list. (line 23)
* -cons*: Other list operations.
(line 30)
* -cons-pair?: Predicates. (line 126)
* -cons-pair?: Predicates. (line 167)
* -const: Function combinators.
(line 101)
* -contains?: Predicates. (line 59)
(line 128)
* -contains?: Predicates. (line 100)
* -copy: Maps. (line 139)
* -count: Reductions. (line 172)
* -cut: Function combinators.
(line 113)
(line 140)
* -cycle: Other list operations.
(line 180)
* -difference: Set operations. (line 20)
@ -4273,8 +4339,9 @@ Index
* -each-while: Side effects. (line 24)
* -elem-index: Indexing. (line 9)
* -elem-indices: Indexing. (line 21)
* -every: Predicates. (line 23)
* -fifth-item: Other list operations.
(line 330)
(line 315)
* -filter: Sublist selection. (line 8)
* -find-index: Indexing. (line 32)
* -find-indices: Indexing. (line 60)
@ -4282,17 +4349,17 @@ Index
* -first: Other list operations.
(line 246)
* -first-item: Other list operations.
(line 287)
(line 272)
* -fix: Other list operations.
(line 390)
(line 375)
* -fixfn: Function combinators.
(line 184)
(line 224)
* -flatten: List to list. (line 34)
* -flatten-n: List to list. (line 56)
* -flip: Function combinators.
(line 89)
(line 95)
* -fourth-item: Other list operations.
(line 320)
(line 305)
* -grade-down: Indexing. (line 81)
* -grade-up: Indexing. (line 71)
* -group-by: Partitioning. (line 194)
@ -4307,24 +4374,24 @@ Index
* -intersection: Set operations. (line 32)
* -iota: Other list operations.
(line 78)
* -is-infix?: Predicates. (line 112)
* -is-prefix?: Predicates. (line 88)
* -is-suffix?: Predicates. (line 100)
* -is-infix?: Predicates. (line 153)
* -is-prefix?: Predicates. (line 129)
* -is-suffix?: Predicates. (line 141)
* -iterate: Unfolding. (line 9)
* -iteratefn: Function combinators.
(line 161)
(line 201)
* -juxt: Function combinators.
(line 37)
* -keep: List to list. (line 8)
* -lambda: Binding. (line 247)
* -last: Other list operations.
(line 277)
(line 262)
* -last-item: Other list operations.
(line 340)
(line 325)
* -let: Binding. (line 61)
* -let*: Binding. (line 227)
* -list: Other list operations.
(line 373)
(line 358)
* -map: Maps. (line 10)
* -map-first: Maps. (line 38)
* -map-indexed: Maps. (line 66)
@ -4336,14 +4403,14 @@ Index
* -min: Reductions. (line 262)
* -min-by: Reductions. (line 272)
* -non-nil: Sublist selection. (line 94)
* -none?: Predicates. (line 32)
* -none?: Predicates. (line 73)
* -not: Function combinators.
(line 126)
(line 153)
* -on: Function combinators.
(line 75)
* -only-some?: Predicates. (line 44)
* -only-some?: Predicates. (line 85)
* -orfn: Function combinators.
(line 135)
(line 167)
* -pad: Other list operations.
(line 191)
* -partial: Function combinators.
@ -4361,7 +4428,7 @@ Index
* -permutations: Set operations. (line 52)
* -powerset: Set operations. (line 44)
* -prodfn: Function combinators.
(line 218)
(line 258)
* -product: Reductions. (line 201)
* -reduce: Reductions. (line 53)
* -reduce-from: Reductions. (line 8)
@ -4385,13 +4452,15 @@ Index
* -replace-last: List to list. (line 96)
* -rotate: Other list operations.
(line 8)
* -rotate-args: Function combinators.
(line 112)
* -rpartial: Function combinators.
(line 22)
* -running-product: Reductions. (line 211)
* -running-sum: Reductions. (line 190)
* -same-items?: Predicates. (line 74)
* -same-items?: Predicates. (line 115)
* -second-item: Other list operations.
(line 300)
(line 285)
* -select-by-indices: Sublist selection. (line 208)
* -select-column: Sublist selection. (line 238)
* -select-columns: Sublist selection. (line 219)
@ -4400,13 +4469,12 @@ Index
* -slice: Sublist selection. (line 104)
* -snoc: Other list operations.
(line 43)
* -some: Other list operations.
(line 262)
* -some: Predicates. (line 8)
* -some-->: Threading macros. (line 86)
* -some->: Threading macros. (line 62)
* -some->>: Threading macros. (line 74)
* -sort: Other list operations.
(line 360)
(line 345)
* -splice: Maps. (line 95)
* -splice-list: Maps. (line 115)
* -split-at: Partitioning. (line 8)
@ -4423,7 +4491,7 @@ Index
* -take-last: Sublist selection. (line 133)
* -take-while: Sublist selection. (line 175)
* -third-item: Other list operations.
(line 310)
(line 295)
* -tree-map: Tree operations. (line 28)
* -tree-map-nodes: Tree operations. (line 39)
* -tree-mapreduce: Tree operations. (line 84)
@ -4528,137 +4596,139 @@ Node: Unfolding37244
Ref: -iterate37485
Ref: -unfold37932
Node: Predicates38737
Ref: -any?38914
Ref: -all?39234
Ref: -none?39564
Ref: -only-some?39866
Ref: -contains?40351
Ref: -same-items?40740
Ref: -is-prefix?41125
Ref: -is-suffix?41451
Ref: -is-infix?41777
Ref: -cons-pair?42131
Node: Partitioning42456
Ref: -split-at42644
Ref: -split-with43308
Ref: -split-on43708
Ref: -split-when44381
Ref: -separate45018
Ref: -partition45457
Ref: -partition-all45906
Ref: -partition-in-steps46331
Ref: -partition-all-in-steps46825
Ref: -partition-by47307
Ref: -partition-by-header47685
Ref: -partition-after-pred48286
Ref: -partition-before-pred48733
Ref: -partition-before-item49118
Ref: -partition-after-item49425
Ref: -group-by49727
Node: Indexing50160
Ref: -elem-index50362
Ref: -elem-indices50757
Ref: -find-index51137
Ref: -find-last-index51626
Ref: -find-indices52130
Ref: -grade-up52535
Ref: -grade-down52942
Node: Set operations53356
Ref: -union53539
Ref: -difference53977
Ref: -intersection54389
Ref: -powerset54821
Ref: -permutations55031
Ref: -distinct55327
Node: Other list operations55701
Ref: -rotate55926
Ref: -repeat56293
Ref: -cons*56572
Ref: -snoc56988
Ref: -interpose57398
Ref: -interleave57692
Ref: -iota58058
Ref: -zip-with58541
Ref: -zip59255
Ref: -zip-lists60084
Ref: -zip-fill60782
Ref: -unzip61104
Ref: -cycle61846
Ref: -pad62245
Ref: -table62564
Ref: -table-flat63350
Ref: -first64355
Ref: -some64841
Ref: -last65325
Ref: -first-item65659
Ref: -second-item66058
Ref: -third-item66322
Ref: -fourth-item66584
Ref: -fifth-item66850
Ref: -last-item67112
Ref: -butlast67403
Ref: -sort67648
Ref: -list68134
Ref: -fix68703
Node: Tree operations69192
Ref: -tree-seq69388
Ref: -tree-map70243
Ref: -tree-map-nodes70683
Ref: -tree-reduce71530
Ref: -tree-reduce-from72412
Ref: -tree-mapreduce73012
Ref: -tree-mapreduce-from73871
Ref: -clone75156
Node: Threading macros75483
Ref: ->75708
Ref: ->>76196
Ref: -->76699
Ref: -as->77255
Ref: -some->77709
Ref: -some->>78082
Ref: -some-->78517
Ref: -doto79066
Node: Binding79619
Ref: -when-let79826
Ref: -when-let*80281
Ref: -if-let80804
Ref: -if-let*81164
Ref: -let81781
Ref: -let*87853
Ref: -lambda88790
Ref: -setq89596
Node: Side effects90397
Ref: -each90591
Ref: -each-while91112
Ref: -each-indexed91714
Ref: -each-r92300
Ref: -each-r-while92736
Ref: -dotimes93362
Node: Destructive operations93915
Ref: !cons94133
Ref: !cdr94337
Node: Function combinators94530
Ref: -partial94734
Ref: -rpartial95252
Ref: -juxt95900
Ref: -compose96352
Ref: -applify96959
Ref: -on97389
Ref: -flip97913
Ref: -const98224
Ref: -cut98562
Ref: -not99042
Ref: -orfn99351
Ref: -andfn99784
Ref: -iteratefn100278
Ref: -fixfn100980
Ref: -prodfn102536
Node: Development103594
Node: Contribute103883
Node: Contributors104895
Node: FDL106988
Node: GPL132308
Node: Index170057
Ref: -some38914
Ref: -every39331
Ref: -any?40010
Ref: -all?40341
Ref: -none?41048
Ref: -only-some?41350
Ref: -contains?41835
Ref: -same-items?42224
Ref: -is-prefix?42609
Ref: -is-suffix?42935
Ref: -is-infix?43261
Ref: -cons-pair?43615
Node: Partitioning43940
Ref: -split-at44128
Ref: -split-with44792
Ref: -split-on45192
Ref: -split-when45863
Ref: -separate46500
Ref: -partition46939
Ref: -partition-all47388
Ref: -partition-in-steps47813
Ref: -partition-all-in-steps48307
Ref: -partition-by48789
Ref: -partition-by-header49167
Ref: -partition-after-pred49768
Ref: -partition-before-pred50215
Ref: -partition-before-item50600
Ref: -partition-after-item50907
Ref: -group-by51209
Node: Indexing51642
Ref: -elem-index51844
Ref: -elem-indices52239
Ref: -find-index52619
Ref: -find-last-index53108
Ref: -find-indices53612
Ref: -grade-up54017
Ref: -grade-down54424
Node: Set operations54838
Ref: -union55021
Ref: -difference55459
Ref: -intersection55871
Ref: -powerset56303
Ref: -permutations56513
Ref: -distinct56809
Node: Other list operations57183
Ref: -rotate57408
Ref: -repeat57761
Ref: -cons*58040
Ref: -snoc58456
Ref: -interpose58866
Ref: -interleave59160
Ref: -iota59526
Ref: -zip-with60009
Ref: -zip60723
Ref: -zip-lists61552
Ref: -zip-fill62250
Ref: -unzip62572
Ref: -cycle63314
Ref: -pad63713
Ref: -table64032
Ref: -table-flat64818
Ref: -first65823
Ref: -last66309
Ref: -first-item66643
Ref: -second-item67042
Ref: -third-item67306
Ref: -fourth-item67568
Ref: -fifth-item67834
Ref: -last-item68096
Ref: -butlast68387
Ref: -sort68632
Ref: -list69118
Ref: -fix69687
Node: Tree operations70176
Ref: -tree-seq70372
Ref: -tree-map71227
Ref: -tree-map-nodes71667
Ref: -tree-reduce72514
Ref: -tree-reduce-from73396
Ref: -tree-mapreduce73996
Ref: -tree-mapreduce-from74855
Ref: -clone76140
Node: Threading macros76467
Ref: ->76692
Ref: ->>77180
Ref: -->77683
Ref: -as->78239
Ref: -some->78693
Ref: -some->>79066
Ref: -some-->79501
Ref: -doto80050
Node: Binding80603
Ref: -when-let80810
Ref: -when-let*81265
Ref: -if-let81788
Ref: -if-let*82148
Ref: -let82765
Ref: -let*88837
Ref: -lambda89774
Ref: -setq90580
Node: Side effects91381
Ref: -each91575
Ref: -each-while92096
Ref: -each-indexed92698
Ref: -each-r93284
Ref: -each-r-while93720
Ref: -dotimes94346
Node: Destructive operations94899
Ref: !cons95117
Ref: !cdr95321
Node: Function combinators95514
Ref: -partial95718
Ref: -rpartial96236
Ref: -juxt96884
Ref: -compose97336
Ref: -applify97943
Ref: -on98373
Ref: -flip99145
Ref: -rotate-args99669
Ref: -const100298
Ref: -cut100640
Ref: -not101120
Ref: -orfn101646
Ref: -andfn102408
Ref: -iteratefn103164
Ref: -fixfn103866
Ref: -prodfn105422
Node: Development106480
Node: Contribute106769
Node: Contributors107781
Node: FDL109874
Node: GPL135194
Node: Index172943

End Tag Table