axiom-developer
[Top][All Lists]

RE: [Axiom-developer] what is meaining of % in SPAD

 From: Page, Bill Subject: RE: [Axiom-developer] what is meaining of % in SPAD Date: Thu, 21 Jul 2005 05:59:35 -0400

On Wednesday, July 20, 2005 7:39 PM I wrote:

> The position in the cashe in turn is determined by the following
> deeply mysterious function:
>
>     triage(k1, k2) ==
>       k1.nest   ^= k2.nest   => B2Z(k1.nest   < k2.nest)
>       k1.op ^= k2.op => B2Z(k1.op < k2.op)
>       (n1 := #(argument k1)) ^= (n2 := #(argument k2)) => B2Z(n1 < n2)
>       ((func := property(operator k1, SPECIALEQUAL)) case None) and
>         (((func::None) pretend ((%, %) -> Boolean)) (k1, k2)) => 0
>       for x1 in argument(k1) for x2 in argument(k2) repeat
>         x1 ^= x2 => return B2Z(x1 < x2)
>       0
>
> In any case, it seems that as symbols %e ends up at a higher location
> in the cache then %pi inspite of the numerical values that they (usually)
> represent. Perhaps, if we really would like the ordering in EXPR INT
> to be less surprizing to the novice user of Axiom, then we need to
> tweak the above routine.

I have an example of such a change here:

http://page.axiom-developer.org/zope/mathaction/SandBoxKernel

triage(k1, k2) ==
is?(k1,pi) and is?(k2,exp) =>  1
is?(k2,pi) and is?(k1,exp) => -1
...

does the "trick" by making sure that any exp() expression gets sorted
before any pi() expression, but I am not really happy with this. Ideally
I would like triage to attempt to compare the numerical values of
expressions if at all possible - something like this:

triage(k1, k2) ==
n1:=numericIfCan(k1::S)
n2:=numericIfCan(k2::S)
n1 case Float and n2 case Float => B2Z(n1<n2)
...

except I cannot figure out how to persuade the compiler to do the
necessary coercions and call the 'numericIfCan' function.

Does anyone have some ideas about how to do this?

Regards,
Bill Page.

reply via email to