CheckArgs
validate a list of Maple expressions
Calling Sequence
Parameters
Description
Examples
CheckArgs(exprs, tests)
exprs
-
list of expressions to validate
tests
list of tests to apply
The CheckArgs routine returns true if all tests pass, and returns false otherwise.
CheckArgs is intended to be used inside an ASSERT() call to perform simple validation of the arguments to a procedure:
ASSERT( CheckArgs( [args], [tests] ), `CheckArgs/Msg` );
The global variable `CheckArgs/Msg` is set to a diagnostic message indicating the first argument whose test failed. The message appears only if assertions are enabled and some test fails.
The tests argument consists of a list of tests, which can be either types or predicates, that is, one-argument functions that return true or false. If the procedure does not return false, then the test passes, otherwise it fails. CheckArgs applies the nth test (that is, the nth element of tests) to the nth element of exprs. Thus, CheckArgs cannot be used for tests involving more than one argument at a time.
CheckArgs⁡hello,1,string,posint
true
See Also
assert
procedure
type
Download Help Document