On 10/03/2013 11:33 PM, Robert Dodier wrote:
> On 2013-10-03, Stavros Macrakis <macrakis at alum.mit.edu> wrote:
>
> > Not sure what you mean about op of an atom -- that is currently an error;
> > are you proposing something else?
>
> Right, at present op(<atom>) is an error. But there exists at least one
> computer algebra system (That Which Shall Not Be Named) in which the
> equivalent operation returns the type of the atom. I was just trying to
> indicate something of the range of possibilities.
I have implemented that in my own private maxima:
(%i1) inflag:true$
(%i2) map('length,["cat",-1,1,1b0,1e0,1/4,-1/4]);
(%o2) [0, 0, 0, 0, 0, 0, 0]
(%i3) map('op,["cat",-1,1,1b0,1e0,1/4,-1/4]);
(%o3) [string, integer, integer, bfloat, float, ratio, ratio]
(%i4) inflag:false$
(%i5) map('length,["cat",-1,1,1b0,1e0,1/4,-1/4]);
(%o5) [0, 1, 0, 0, 0, 0, 1]
(%i6) map('op,["cat",-1,1,1b0,1e0,1/4,-1/4]);
(%o6) [string, integer, integer, bfloat, float, /, -]
The test suite passes, but inflag has to be false anyway for
the testsuite. I'd be surprised if it did not break some code.
The following also does not break the test suite.
(%i2) length();
Warning: length: length called with zero arguments; one argument is
expected.
(%o2) length()
(%i3) length(1,2);
Warning: length: length called with two arguments; one argument is expected.
(%o3) length(1, 2)
(%i4) op();
Warning: op: op called with zero arguments; one argument is expected.
(%o4) op()
(%i5) op("cat","dog");
Warning: op: op called with two arguments; one argument is expected.
(%o5) op(cat, dog)
(%i6) cons(x,3);
Warning: cons: Argument '3' at position 2 is not a non-atomic expression
in cons(x,3).
(%o6) cons(x, 3)
(%i7) unset_match_form('cons);
(%o7) done
(%i8) cons(x,3);
cons: Argument '3' at position 2 is not a non-atomic expression in
cons(x,3).
(%i9) error_code;
(%o9) chk_atomchk
--John