argument checking, was: About submatrix and its meaning



On 11/21/09, Kostas Oikonomou <ko at research.att.com> wrote:

> How about a question mark?  E.g. "x?listp".
>
> foo(P(x)) is too much like f(g(x)), function composition.

Well, it turns out "?" interferes with the use of ? to indicate
Lisp symbols. But "??" is OK.

Here's a first attempt to use "??" expressions to indicate
argument-checking predicates in function definitions.

foo (x??integerp) := ifactors (x);
foo (1234);
 => [[2, 1], [617, 1]]
foo (a + 1);
 => foo: expected argument x to satisfy integerp test; found: a + 1
bar (a ?? lambda ([x], is (abs (x) < 1))) := 1/(1 - a);
bar (1/2);
 => 2
bar (2);
 => bar: expected argument a to satisfy lambda([x], is(abs(x) < 1))
                                                   test; found: 2


What do you think? Patch attached.

FWIW

Robert Dodier
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mdefine-predicate-patch
Type: application/octet-stream
Size: 3973 bytes
Desc: not available
Url : http://www.math.utexas.edu/pipermail/maxima/attachments/20091122/357f0381/attachment.obj