determine whether all elements of a generated sequence are true
determine whether any elements of a generated sequence are true
determine whether an odd number of elements of a generated sequence are true
andseq(f, i = m..n, step)
andseq(f, i = x)
andseq(f, i in x)
orseq(f, i = m..n, step)
orseq(f, i = x)
orseq(f, i in x)
xorseq(f, i = m..n, step)
xorseq(f, i = x)
xorseq(f, i in x)
expression that evaluates to a Boolean value
(optional) numerical value
The andseq, orseq, and xorseq functions conceptually construct a sequence of values, and then use the elements of that sequence as operands of the corresponding Boolean operator (and, or, or xor). The return value will be true, false, or FAIL.
Semantically, andseq( ... ) is equivalent to `and`(seq( ... )), except that the sequence is not actually constructed in memory. A similar equivalence holds true for orseq and xorseq.
In the case of andseq and orseq only, McCarthy short-circuit evaluation rules are used. As soon as the result is known (false if any element in andseq is found to be false, or true if any element in orseq is found to be true), computation of the sequence terminates and the result is returned.
In the interest of brevity, in the paragraphs below, descriptions of the operation of andseq should be understood to apply to orseq and xorseq as well.
For some expression f(i), the sequence for andseq(f(i), i=m..n) computes f(i) for each value of i in [m, m+1, ..., n].
If the optional step argument is given, f(i) is computed for each value of i in [m, m+step, ..., n].
The sequence for andseq(f(i), i = x) or andseq(f(i), i in x) is computed by applying f to each operand or entry of x. Here, x is most commonly a set or list, but can be any other data structure to which op or entries can be applied, such as a sum, product, Array, or Matrix.
The form, andseq('x'), is equivalent to andseq(i, i = x). For this to be meaningful, x must contain only Boolean values.
When x is a sparse Matrix, Vector, or Array, only the nonzero entries are scanned. Otherwise, regardless of the indexing function, or storage, the entire index space of the object is scanned.
The index variable i refers to the instance of the variable that is in scope in the context where the call to andseq occurs. At the top-level (outside of any procedure or module), the global variable is used. Within a procedure or module, the local variable of that name is used. If the procedure or module does not explicitly declare a local variable with that name, an implicit local declaration is quietly generated.
Regardless of whether the index variable is local or global, the value that the variable had before the invocation of andseq is restored afterwards. Thus the value of that variable is not affected.
The andseq, orseq, and xorseq commands are thread safe as of Maple 2021 provided that evaluating f is itself thread safe. Further, the index variable i must not be shared between threads. Using a procedure local is advised.
For more information on thread safety, see index/threadsafe.
Do all the terms in a sum contain an integration?
Check if a column of a Matrix contains a particular value.
The andseq, orseq and xorseq commands were introduced in Maple 2021.
For more information on Maple 2021 changes, see Updates in Maple 2021.
Download Help Document
What kind of issue would you like to report? (Optional)