Maple für Professional
Maple für Akademiker
Maple für Studenten
Maple Personal Edition
Maple Player
Maple Player für iPad
MapleSim für Professional
MapleSim für Akademiker
Maple T.A. - Testen & beurteilen
Maple T.A. MAA Placement Test Suite
Möbius - Online-Courseware
Machine Design / Industrial Automation
Luft- und Raumfahrt
Fahrzeugtechnik
Robotics
Energiebranche
System Simulation and Analysis
Model development for HIL
Anlagenmodelle für den Regelungsentwurf
Robotics/Motion Control/Mechatronics
Other Application Areas
Mathematikausbildung
Technik
Allgemein- und berufsbildende Schulen
Testen und beurteilen
Studierende
Finanzmodelle
Betriebsforschung
Hochleistungsrechnen
Physik
Live-Webinare
Aufgezeichnete Webinare
Geplante Veranstaltungen
MaplePrimes
Maplesoft-Blog
Maplesoft-Mitgliedschaft
Maple Ambassador Program
MapleCloud
Technische Whitepapers
E-Mail Newsletters
Maple-Bücher
Math Matters
Anwendungs-Center
MapleSim Modell-Galerie
Anwenderberichte
Exploring Engineering Fundamentals
Lehrkonzepte mit Maple
Maplesoft Welcome-Center
Resource-Center für Lehrer
Help-Center für Studierende
andmap - determine whether a predicate is true of all operands of an expression
ormap - determine whether a predicate is true of some operands of an expression
Calling Sequence
andmap(p, expr, ...)
ormap(p, expr, ...)
Parameters
p
-
predicate returning either true or false
expr
expression
...
(optional) other arguments to pass to p
Description
The procedures andmap and ormap determine whether a predicate p returns true or false for all or some operands of an expression expr.
If expr is atomic, both andmap(p, expr, ...) and ormap(p, expr, ...) are equivalent to p(expr, ... ).
In general, andmap(p, expr, ...) returns true if p(opnd, ...) is true for all operands opnd of expr, and returns false otherwise.
Similarly, ormap(p, expr, ...) returns false if p(opnd, ...) is false for all operands opnd of expr, and returns true otherwise.
Both andmap and ormap have short-circuit ("McCarthy") semantics, which means that an answer is returned as soon as it can be determined. The predicate only evaluates at the operands of the expression expr until the result can be determined. The order in which the operands are examined is not specified. You should not rely on side effects of the predicate p.
For a table or array, p is applied to each entry of the table or array.
Since strings are atomic expressions in Maple, you cannot map a procedure over a string by using andmap and ormap. However, the StringTools package contains the exports AndMap and OrMap that provide this functionality.
Thread Safety
The andmap and ormap commands are thread safe as of Maple 15, provided that evaluating the expression p is thread safe.
For more information on thread safety, see index/threadsafe.
Examples
This examples illustrates a technique for quickly destructuring a record.
RecordSlots := proc( r::record ) if not type( [ args[ 2 .. nargs ] ], 'list( symbol )' ) then error "arguments after the first must be of type `symbol'" end if; andmap( e -> member( cat( e ), r, e ), [ args[ 2 .. nargs ] ] ) end proc:
See Also
curry, map, op, rcurry, select, spec_eval_rules, StringTools, StringTools[AndMap], StringTools[OrMap], type[atomic]
Download Help Document