[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-developer] [Axiom-mail] Lexicographic order
From: |
Martin Rubey |
Subject: |
[Axiom-developer] [Axiom-mail] Lexicographic order |
Date: |
Mon, 29 Aug 2005 04:31:46 -0500 |
Changes http://page.axiom-developer.org/zope/mathaction/AxiomMail/diff
--
Dear Jens,
Although I'm not 100% sure what lexorder? ought to do exactly, you might want
to notice the following:
the first matching type the interpreter finds for [x,y,z] is
(13) -> [x,y,z]
(13) [x,y,z]
Type: List OrderedVariableList [x,y,z]
which means that in sort([x,z,y]) you are using the order imposed by
OrderedVariableList [x,y,z], which is z < y < x.
So, although
> > sort([x,y,z])
> [z,y,x]
>
> > sort([x,z,y])
> [y,z,x]
is surprising, it shouldn't be ;-) (<- please note the smiley !)
If you say
sort([x,z,y]::List Symbol), you will get the expected output.
I'm not totally sure how you can find out what ordering a domain uses. But very
likely, if its name doesn't contain something like "Ordered", it is the usual
lexicographic order.
Hope this helps,
Martin
Jens Axel S�gaard writes:
> Hi all,
>
> Is there a smarter way than the following to write lexorder?(p,q) ?
>
> lexorder?(p,q) ==
> if empty?(variables(p))
> then return ~empty(variables(q))
> else
> vars := members(difference( set(variables( secret1*p + secret2*q)),
> set([secret1, secret2])))
> a := members(degree( p::DMP(vars,?) ))
> b := members(degree( q::DMP(vars,?) ))
> return negative?( first(a) - first(b) )
>
>
> My first attempt used:
>
> vars := sort(members(union(set(variables(p), variables(q)))))
>
> but was surprised to see
>
> > sort([x,y,z])
> [z,y,x]
>
> > sort([x,z,y])
> [y,z,x]
>
> and thus made up the secret-trick in order to avoid sort.
>
> --
> Jens Axel S�gaard
>
>
>
> _______________________________________________
> Axiom-mail mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/axiom-mail
>
_______________________________________________
Axiom-mail mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/axiom-mail
--
forwarded from http://page.axiom-developer.org/zope/mathaction/address@hidden