Sponsored links: Algebra eBooks
 

Help Index

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

The Maxima on-line user's manual

Algebra Calculator

Search:

Every Calculator

Every

Function: every (<f>, <s>)

Function: every (<f>, <L_1>, ..., <L_n>) Returns true if the predicate <f> is true for all given arguments.

Given one set as the second argument, every(<f>, <s>) returns true if is(<f>(<a_i>)) returns true for all <a_i> in <s>. every may or may not evaluate <f> for all <a_i> in <s>. Since sets are unordered, every may evaluate <f>(<a_i>) in any order.

Given one or more lists as arguments, every(<f>, <L_1>, ..., <L_n>) returns true if is(<f>(<x_1>, ..., <x_n>)) returns true for all <x_1>, ..., <x_n> in <L_1>, ..., <L_n>, respectively. every may or may not evaluate <f> for every combination <x_1>, ..., <x_n>. every evaluates lists in the order of increasing index.

Given an empty set {} or empty lists [] as arguments, every returns false.

When the global flag maperror is true, all lists <L_1>, ..., <L_n> must have equal lengths. When maperror is false, list arguments are effectively truncated to the length of the shortest list.

Return values of the predicate <f> which evaluate (via is) to something other than true or false are governed by the global flag prederror. When prederror is true, such values are treated as false, and the return value from every is false. When prederror is false, such values are treated as unknown, and the return value from every is unknown.

Examples:

every applied to a single set. The predicate is a function of one argument.

          (%i1) every (integerp, {1, 2, 3, 4, 5, 6});
          (%o1)                         true
          (%i2) every (atom, {1, 2, sin(3), 4, 5 + y, 6});
          (%o2)                         false

every applied to two lists. The predicate is a function of two arguments.

          (%i1) every ("=", [a, b, c], [a, b, c]);
          (%o1)                         true
          (%i2) every ("#", [a, b, c], [a, b, c]);
          (%o2)                         false

Return values of the predicate <f> which evaluate to something other than true or false are governed by the global flag prederror.

          (%i1) prederror : false;
          (%o1)                         false
          (%i2) map (lambda ([a, b], is (a < b)), [x, y, z],
                             [x^2, y^2, z^2]);
          (%o2)              [unknown, unknown, unknown]
          (%i3) every ("<", [x, y, z], [x^2, y^2, z^2]);
          (%o3)                        unknown
          (%i4) prederror : true;
          (%o4)                         true
          (%i5) every ("<", [x, y, z], [x^2, y^2, z^2]);
          (%o5)                         false

(%o1)                                true
(%i2) 

Every Example

Related Examples

every-is-lambda-matrix-rank-row

m: matrix([1,2,3],[0,...

rank(m);

r: row(m,3);

Calculate

every-is-lambda-matrix-rank-row

m: matrix([1,2,3],[0,...

rank(m);

r: row(m,3);

Calculate

every-is-lambda-matrix-rank-row

m: matrix([1,2,3],[0,...

rank(m);

r: row(m,3);

Calculate

every-is-lambda-matrix-rank-row-submatrix

m: matrix([1,2,3],[0,...

rank(m);

r: row(m,3);

Calculate

every-false-is-lambda-map-prederror-sin-true

every (integerp, {1, ...

every (atom, {1, 2, ...

every ("=", [a, b, c...

Calculate

every-is-lambda-matrix-rank-row

m: matrix([1,2,3],[0,...

rank(m);

r: row(m,3);

Calculate

every-is-lambda-matrix-rank-row

m: matrix([1,2,3],[0,...

rank(m);

r: row(m,3);

Calculate

every-is-lambda-matrix-rank-row-submatrix

m: matrix([1,2,3],[0,...

rank(m);

r: row(m,3);

Calculate