axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Axiom-developer] pointers


From: William Sit
Subject: Re: [Axiom-developer] pointers
Date: Tue, 10 Nov 2009 11:38:25 -0500

Thanks, Tim. That is exactly what I am looking for. Now I would like to compare c.1 with some known constructor, say Fraction. (In other words, given a domain of category Field, I would like to know if it comes from the constructor Fraction). I tried a few variations and each time, Axiom says:

Although Fraction is the name of a constructor, a full type must be specified in the context you have used it. Issue )show Fraction for more information.

Things I tried:

a:=FiniteField(5,2)
b:=devaluate(a)$Lisp
c:=destruct(b)
c.1
d:="Fraction"::SExpression
e:Boolean
e:=EQ(c.1,d)  -- message above
e:=(c.1=Fraction)  -- message above
e:= (c.1=d$Lisp) -- message above
a1:=Fraction Integer
b1:=devaluate(a1)$Lisp
c1:=destruct(b1)
e:=(c.1=c1.1) -- message above

I confess that I'm still using a very old Window version (Version of Tuesday November 30, 2004 at 21:11:14) but I don't think that makes a difference in these examples.

William

On Mon, 09 Nov 2009 21:24:48 -0500
 Tim Daly <address@hidden> wrote:
I'm not sure what you want. Perhaps you'd like to say:

a:=Fraction(Polynomial(Integer))
b:=devaluate(a)$Lisp

which returns the list (actually of type SExpression)

(Fraction (Polynomial (Integer)))

c:=destruct(b)
c.2

which returns (Polynomial (Integer))

Does that help?

Tim


William Sit wrote:
Tim:

Interesting. Is there a similar function that is more structural? say, can I test whether some domain (which may be passed as a parameter of type Field) is of the form Fraction(something) and if so, extract "something" (that is, assign it to a variable and further test it), sort of a deconstruction?

William

On Mon, 09 Nov 2009 19:51:45 -0500
Tim Daly <address@hidden> wrote:
You can get a memory pointer to a lisp object.

a:=Fraction(Integer)

returns the "memory location of Fraction(Integer)"
You can prove this with

b:=Fraction(Integer)
EQ(a,b)$Lisp

The lisp function EQ compares memory pointers.

There is a lisp function to get the hash value of any object
call sxhash. You can call it.

SXHASH(a)$Lisp

Note that if

c:=Integer

then
EQ(a,c)$Lisp is false
SXHASH(a)$Lisp is not equal to SXHASH(c)$Lisp

Thus the hash function you seek already exists.
You just have to accept the fact that Spad is only syntactic
sugar for lisp code and lisp is not evil.

Tim



_______________________________________________
Axiom-developer mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/axiom-developer

William Sit, Professor Emeritus
Mathematics, City College of New York Office: R6/202C Tel: 212-650-5179
Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/



William Sit, Professor Emeritus
Mathematics, City College of New York Office: R6/202C Tel: 212-650-5179
Home Page: http://scisun.sci.ccny.cuny.edu/~wyscc/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]