login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Submitted by : (unknown) at: 2007-11-17T22:19:51-08:00 (16 years ago)
Name :
Axiom Version :
Category : Severity : Status :
Optional subject :  
Optional comment :

I make a list :

fricas
L := map (t +-> [t, divide (10*t,21)], expand (1..21-1))

\label{eq1}\begin{array}{@{}l}
\displaystyle
\left[{\left[ 1, \:{\left[{quotient = 0}, \:{remainder ={10}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 2, \:{\left[{quotient = 0}, \:{remainder ={20}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 3, \:{\left[{quotient = 1}, \:{remainder = 9}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 4, \:{\left[{quotient = 1}, \:{remainder ={19}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 5, \:{\left[{quotient = 2}, \:{remainder = 8}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 6, \:{\left[{quotient = 2}, \:{remainder ={18}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 7, \:{\left[{quotient = 3}, \:{remainder = 7}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 8, \:{\left[{quotient = 3}, \:{remainder ={17}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 9, \:{\left[{quotient = 4}, \:{remainder = 6}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{10}, \:{\left[{quotient = 4}, \:{remainder ={16}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{11}, \:{\left[{quotient = 5}, \:{remainder = 5}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{12}, \:{\left[{quotient = 5}, \:{remainder ={15}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{13}, \:{\left[{quotient = 6}, \:{remainder = 4}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{14}, \:{\left[{quotient = 6}, \:{remainder ={14}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{15}, \:{\left[{quotient = 7}, \:{remainder = 3}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{16}, \:{\left[{quotient = 7}, \:{remainder ={13}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{17}, \:{\left[{quotient = 8}, \:{remainder = 2}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{18}, \:{\left[{quotient = 8}, \:{remainder ={12}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{19}, \:{\left[{quotient = 9}, \:{remainder = 1}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{20}, \:{\left[{quotient = 9}, \:{remainder ={11}}\right]}\right]}\right] (1)
Type: List(List(Any))

I can't extract the second term :

fricas
select (t +-> t.1=2, L)
empty

\label{eq2}\left[ \right](2)
Type: List(List(Any))

I get an error :

fricas
select (t +-> (t.2).remainder = 1, L)             -- erreur
There are 1 exposed and 1 unexposed library operations named elt having 1 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op elt to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation. There are no library operations named G705 Use HyperDoc Browse or issue )what op G705 to learn if there is any operation containing " G705 " in its name. There are 1 exposed and 1 unexposed library operations named elt having 1 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op elt to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation. There are 4 exposed and 1 unexposed library operations named select having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op select to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named select with argument type(s) AnonymousFunction List(List(Any))
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

It seems right :

fricas
Lc := reduce (append, L)

\label{eq3}\begin{array}{@{}l}
\displaystyle
\left[ 1, \:{\left[{quotient = 0}, \:{remainder ={10}}\right]}, \: 2, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 0}, \:{remainder ={20}}\right]}, \: 3, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 1}, \:{remainder = 9}\right]}, \: 4, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 1}, \:{remainder ={19}}\right]}, \: 5, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 2}, \:{remainder = 8}\right]}, \: 6, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 2}, \:{remainder ={18}}\right]}, \: 7, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 3}, \:{remainder = 7}\right]}, \: 8, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 3}, \:{remainder ={17}}\right]}, \: 9, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 4}, \:{remainder = 6}\right]}, \:{10}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 4}, \:{remainder ={16}}\right]}, \:{1
1}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 5}, \:{remainder = 5}\right]}, \:{12}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 5}, \:{remainder ={15}}\right]}, \:{1
3}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 6}, \:{remainder = 4}\right]}, \:{14}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 6}, \:{remainder ={14}}\right]}, \:{1
5}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 7}, \:{remainder = 3}\right]}, \:{16}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 7}, \:{remainder ={13}}\right]}, \:{1
7}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 8}, \:{remainder = 2}\right]}, \:{18}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 8}, \:{remainder ={12}}\right]}, \:{1
9}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 9}, \:{remainder = 1}\right]}, \:{20}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 9}, \:{remainder ={11}}\right]}\right] (3)
Type: List(Any)
fricas
c := Lc.4

\label{eq4}\left[{quotient = 0}, \:{remainder ={20}}\right](4)
Type: Record(quotient: Integer,remainder: Integer)

But I can't get the quotient :

fricas
c.quotient
There are no library operations named c Use HyperDoc Browse or issue )what op c to learn if there is any operation containing " c " in its name.
Cannot find a definition or applicable library operation named c with argument type(s) Variable(quotient)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

divide is right :

fricas
c2 := divide (20, 21)

\label{eq5}\left[{quotient = 0}, \:{remainder ={20}}\right](5)
Type: Record(quotient: Integer,remainder: Integer)
fricas
c2.quotient

\label{eq6}0(6)
Type: NonNegativeInteger?

And all theses commands are right :

fricas
Lb := map (t +-> [t, (10*t) rem 21, (10*t) quo 21], expand (1..21-1))

\label{eq7}\begin{array}{@{}l}
\displaystyle
\left[{\left[ 1, \:{10}, \: 0 \right]}, \:{\left[ 2, \:{20}, \: 0 \right]}, \:{\left[ 3, \: 9, \: 1 \right]}, \:{\left[ 4, \:{19}, \: 1 \right]}, \:{\left[ 5, \: 8, \: 2 \right]}, \:{\left[ 6, \:{18}, \: 2 \right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 7, \: 7, \: 3 \right]}, \:{\left[ 8, \:{17}, \: 3 \right]}, \:{\left[ 9, \: 6, \: 4 \right]}, \:{\left[{10}, \:{16}, \: 4 \right]}, \:{\left[{11}, \: 5, \: 5 \right]}, \:{\left[{1
2}, \:{15}, \: 5 \right]}, \: \right.
\
\
\displaystyle
\left.{\left[{13}, \: 4, \: 6 \right]}, \:{\left[{14}, \:{14}, \: 6 \right]}, \:{\left[{15}, \: 3, \: 7 \right]}, \:{\left[{1
6}, \:{13}, \: 7 \right]}, \:{\left[{17}, \: 2, \: 8 \right]}, \:{\left[{18}, \:{12}, \: 8 \right]}, \: \right.
\
\
\displaystyle
\left.{\left[{19}, \: 1, \: 9 \right]}, \:{\left[{20}, \:{11}, \: 9 \right]}\right] 
(7)
Type: List(List(Integer))
fricas
select (t +-> t.1=2, Lb)

\label{eq8}\left[{\left[ 2, \:{20}, \: 0 \right]}\right](8)
Type: List(List(Integer))
fricas
select (t +-> t.2 = 1, Lb)

\label{eq9}\left[{\left[{19}, \: 1, \: 9 \right]}\right](9)
Type: List(List(Integer))
fricas
reduce (append, Lb)

\label{eq10}\begin{array}{@{}l}
\displaystyle
\left[ 1, \:{10}, \: 0, \: 2, \:{20}, \: 0, \: 3, \: 9, \: 1, \: 4, \:{19}, \: 1, \: 5, \: 8, \: 2, \: 6, \:{18}, \: 2, \: 7, \: 7, \: 3, \: 8, \:{17}, \: \right.
\
\
\displaystyle
\left.3, \: 9, \: 6, \: 4, \:{10}, \:{16}, \: 4, \:{11}, \: 5, \: 5, \:{12}, \:{15}, \: 5, \:{13}, \: 4, \: 6, \:{14}, \:{1
4}, \: 6, \:{15}, \: 3, \: \right.
\
\
\displaystyle
\left.7, \:{16}, \:{13}, \: 7, \:{17}, \: 2, \: 8, \:{18}, \:{1
2}, \: 8, \:{19}, \: 1, \: 9, \:{20}, \:{11}, \: 9 \right] 
(10)
Type: List(Integer)

I don't know why but the result of
fricas
L := map (t +-> [t, divide (10*t,21)], expand (1..21-1))

\label{eq11}\begin{array}{@{}l}
\displaystyle
\left[{\left[ 1, \:{\left[{quotient = 0}, \:{remainder ={10}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 2, \:{\left[{quotient = 0}, \:{remainder ={20}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 3, \:{\left[{quotient = 1}, \:{remainder = 9}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 4, \:{\left[{quotient = 1}, \:{remainder ={19}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 5, \:{\left[{quotient = 2}, \:{remainder = 8}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 6, \:{\left[{quotient = 2}, \:{remainder ={18}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 7, \:{\left[{quotient = 3}, \:{remainder = 7}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 8, \:{\left[{quotient = 3}, \:{remainder ={17}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 9, \:{\left[{quotient = 4}, \:{remainder = 6}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{10}, \:{\left[{quotient = 4}, \:{remainder ={16}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{11}, \:{\left[{quotient = 5}, \:{remainder = 5}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{12}, \:{\left[{quotient = 5}, \:{remainder ={15}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{13}, \:{\left[{quotient = 6}, \:{remainder = 4}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{14}, \:{\left[{quotient = 6}, \:{remainder ={14}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{15}, \:{\left[{quotient = 7}, \:{remainder = 3}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{16}, \:{\left[{quotient = 7}, \:{remainder ={13}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{17}, \:{\left[{quotient = 8}, \:{remainder = 2}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{18}, \:{\left[{quotient = 8}, \:{remainder ={12}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{19}, \:{\left[{quotient = 9}, \:{remainder = 1}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{20}, \:{\left[{quotient = 9}, \:{remainder ={11}}\right]}\right]}\right] (11)
Type: List(List(Any))

is List List Any. So the interpreter seems to be smart to convert this back

fricas
K := first rest first L

\label{eq12}\left[{quotient = 0}, \:{remainder ={10}}\right](12)
Type: Record(quotient: Integer,remainder: Integer)

to Record(quotient: Integer,remainder: Integer). But it only looks like that.

fricas
K.remainder
There are no exposed library operations named K but there is one unexposed operation with that name. Use HyperDoc Browse or issue )display op K to learn more about the available operation.
Cannot find a definition or applicable library operation named K with argument type(s) Variable(remainder)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

gives an error. WHY?

A workaround is the following:

fricas
R := Record(quotient: Integer,remainder: Integer)

\label{eq13}\mbox{\rm \hbox{\axiomType{Record}\ } (quotient : \hbox{\axiomType{Integer}\ } , remainder : \hbox{\axiomType{Integer}\ })}(13)
Type: Type
fricas
H := K :: R

\label{eq14}\left[{quotient = 0}, \:{remainder ={10}}\right](14)
Type: Record(quotient: Integer,remainder: Integer)
fricas
H.remainder

\label{eq15}10(15)
Type: PositiveInteger?

Ralf

Yes, the internal type is Any --greg, Mon, 20 Mar 2006 09:54:30 -0600 reply
The internal types of these objects are of type Any but the interpreter uses the original types when it prints theses objects. See any.spad.pamphlet for information.
fricas
L := map (t +-> [t, divide (10*t,21)], expand (1..5))

\label{eq16}\begin{array}{@{}l}
\displaystyle
\left[{\left[ 1, \:{\left[{quotient = 0}, \:{remainder ={10}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 2, \:{\left[{quotient = 0}, \:{remainder ={20}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 3, \:{\left[{quotient = 1}, \:{remainder = 9}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 4, \:{\left[{quotient = 1}, \:{remainder ={19}}\right]}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 5, \:{\left[{quotient = 2}, \:{remainder = 8}\right]}\right]}\right] (16)
Type: List(List(Any))
fricas
Lc := reduce (append, L)

\label{eq17}\begin{array}{@{}l}
\displaystyle
\left[ 1, \:{\left[{quotient = 0}, \:{remainder ={10}}\right]}, \: 2, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 0}, \:{remainder ={20}}\right]}, \: 3, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 1}, \:{remainder = 9}\right]}, \: 4, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 1}, \:{remainder ={19}}\right]}, \: 5, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 2}, \:{remainder = 8}\right]}\right] (17)
Type: List(Any)
fricas
c := Lc.4

\label{eq18}\left[{quotient = 0}, \:{remainder ={20}}\right](18)
Type: Record(quotient: Integer,remainder: Integer)
fricas
c

\label{eq19}\left[{quotient = 0}, \:{remainder ={20}}\right](19)
Type: Record(quotient: Integer,remainder: Integer)
fricas
)display type c
Type of value of c: Any domainOf(c)

\label{eq20}\hbox{\axiomType{Record}\ } \left({{\left(quotient \  : \  \hbox{\axiomType{Integer}\ } \right)}, \:{\left(remainder \  : \  \hbox{\axiomType{Integer}\ } \right)}}\right)(20)
Type: OutputForm?

property change --greg, Mon, 20 Mar 2006 10:01:12 -0600 reply
Status: open => closed

To extract second term use:
fricas
select(x+->x.1::Integer=2, L)

\label{eq21}\left[{\left[ 2, \:{\left[{quotient = 0}, \:{remainder ={20}}\right]}\right]}\right](21)
Type: List(List(Any))

But I think the 2nd problem requiring the coercion to Record of something that is already apparently of that type is a bug.

Here it's possible to use a Record --greg, Mon, 20 Mar 2006 10:46:06 -0600 reply
fricas
L := map (t +-> makeRecord(t, divide (10*t,21)), expand (1..21-1))

\label{eq22}\begin{array}{@{}l}
\displaystyle
\left[{\left[{part 1 = 1}, \:{part 2 ={\left[{quotient = 0}, \:{remainder ={10}}\right]}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{part 1 = 2}, \:{part 2 ={\left[{quotient = 0}, \:{remainder ={20}}\right]}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{part 1 = 3}, \:{part 2 ={\left[{quotient = 1}, \:{remainder = 9}\right]}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{part 1 = 4}, \:{part 2 ={\left[{quotient = 1}, \:{remainder ={19}}\right]}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{part 1 = 5}, \:{part 2 ={\left[{quotient = 2}, \:{remainder = 8}\right]}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{part 1 = 6}, \:{part 2 ={\left[{quotient = 2}, \:{remainder ={18}}\right]}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{part 1 = 7}, \:{part 2 ={\left[{quotient = 3}, \:{remainder = 7}\right]}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{part 1 = 8}, \:{part 2 ={\left[{quotient = 3}, \:{remainder ={17}}\right]}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{part 1 = 9}, \:{part 2 ={\left[{quotient = 4}, \:{remainder = 6}\right]}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{part 1 ={10}}, \:{part 2 ={\left[{quotient = 4}, \:{remainder ={16}}\right]}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{part 1 ={11}}, \:{part 2 ={\left[{quotient = 5}, \:{remainder = 5}\right]}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{part 1 ={12}}, \:{part 2 ={\left[{quotient = 5}, \:{remainder ={15}}\right]}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{part 1 ={13}}, \:{part 2 ={\left[{quotient = 6}, \:{remainder = 4}\right]}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{part 1 ={14}}, \:{part 2 ={\left[{quotient = 6}, \:{remainder ={14}}\right]}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{part 1 ={15}}, \:{part 2 ={\left[{quotient = 7}, \:{remainder = 3}\right]}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{part 1 ={16}}, \:{part 2 ={\left[{quotient = 7}, \:{remainder ={13}}\right]}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{part 1 ={17}}, \:{part 2 ={\left[{quotient = 8}, \:{remainder = 2}\right]}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{part 1 ={18}}, \:{part 2 ={\left[{quotient = 8}, \:{remainder ={12}}\right]}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{part 1 ={19}}, \:{part 2 ={\left[{quotient = 9}, \:{remainder = 1}\right]}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{part 1 ={20}}, \:{part 2 ={\left[{quotient = 9}, \:{remainder ={11}}\right]}}\right]}\right] 
(22)
Type: List(Record(part1: Integer,part2: Record(quotient: Integer,remainder: Integer)))
fricas
select (t +-> t.part1=2, L)

\label{eq23}\left[{\left[{part 1 = 2}, \:{part 2 ={\left[{quotient = 0}, \:{remainder ={20}}\right]}}\right]}\right](23)
Type: List(Record(part1: Integer,part2: Record(quotient: Integer,remainder: Integer)))
fricas
select (t +-> (t.part2).remainder = 1, L)

\label{eq24}\left[{\left[{part 1 ={19}}, \:{part 2 ={\left[{quotient = 9}, \:{remainder = 1}\right]}}\right]}\right](24)
Type: List(Record(part1: Integer,part2: Record(quotient: Integer,remainder: Integer)))
fricas
L.2.part2.quotient

\label{eq25}0(25)
Type: NonNegativeInteger?

bug report reopened --greg, Mon, 20 Mar 2006 19:40:15 -0600 reply
After reflexion I think I can't take the decision to close this bug report. First, some persons can prefer to have the real type displayed instead of the original one. Second, Bill Page thinks that the 2nd problem requiring the coercion to Record is a bug and third it's not possible to extract element of an object of type Any with Record as its original type but it's possible if the original type is List or Vector for example.
fricas
a:= [[x,2],4,divide(10,7)]

\label{eq26}\left[{\left[ x , \: 2 \right]}, \: 4, \:{\left[{quotient = 1}, \:{remainder = 3}\right]}\right](26)
Type: List(Any)
fricas
b:=a.1

\label{eq27}\left[ x , \: 2 \right](27)
Type: List(Polynomial(Integer))
fricas
)di type b
Type of value of b: Any b.1

\label{eq28}x(28)
Type: Polynomial(Integer)
fricas
c:=a.3

\label{eq29}\left[{quotient = 1}, \:{remainder = 3}\right](29)
Type: Record(quotient: Integer,remainder: Integer)
fricas
)di type c
Type of value of c: Any c.quotient
There are no library operations named c Use HyperDoc Browse or issue )what op c to learn if there is any operation containing " c " in its name.
Cannot find a definition or applicable library operation named c with argument type(s) Variable(quotient)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

property change --greg, Mon, 20 Mar 2006 19:40:57 -0600 reply
Status: closed => open

)set message any off --Bill Page, Tue, 21 Mar 2006 02:09:11 -0600 reply
This command disables the display of the underlying type of an object of type Any.
fricas
)set message any
----------------------------- The any Option ------------------------------
Description: print the internal type of objects of domain Any
The any option may be followed by any one of the following:
-> on off
The current setting is indicated within the list.

With this option off Axiom displays the Type: in the same way as )di type. This might be useful in order to avoid confusion in some cases.

Well, actually, this is one of the problem why people might find it hard to work with Axiom. Of course, Axiom returns for L the best it could. If I write
fricas
ans := [2, divide(10*2,21)]

\label{eq30}\left[ 2, \:{\left[{quotient = 0}, \:{remainder ={20}}\right]}\right](30)
Type: List(Any)

then it is clear that the type over which the list is formed have to be made equal. So we get List Any. But maybe, it would have been wiser if Axiom had warned about such a construction or Axiom should rather interpret the outer brackets in

fricas
[1, [2,3]]

\label{eq31}\left[ 1, \:{\left[ 2, \: 3 \right]}\right](31)
Type: List(Any)

as makeRecord.

fricas
makeRecord(1, [2,3])

\label{eq32}\left[{part 1 = 1}, \:{part 2 ={\left[ 2, \: 3 \right]}}\right](32)
Type: Record(part1: PositiveInteger?,part2: List(PositiveInteger?))

Anyway, the question is also why someone wants to have

fricas
L := map (t +-> [t, divide (10*t,21)], expand (1..21-1));
Type: List(List(Any))

in the first place. Wouldn't be

fricas
LL := map (t +-> divide (10*t,21), expand (1..21-1))

\label{eq33}\begin{array}{@{}l}
\displaystyle
\left[{\left[{quotient = 0}, \:{remainder ={10}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 0}, \:{remainder ={20}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 1}, \:{remainder = 9}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 1}, \:{remainder ={19}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 2}, \:{remainder = 8}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 2}, \:{remainder ={18}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 3}, \:{remainder = 7}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 3}, \:{remainder ={17}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 4}, \:{remainder = 6}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 4}, \:{remainder ={16}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 5}, \:{remainder = 5}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 5}, \:{remainder ={15}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 6}, \:{remainder = 4}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 6}, \:{remainder ={14}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 7}, \:{remainder = 3}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 7}, \:{remainder ={13}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 8}, \:{remainder = 2}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 8}, \:{remainder ={12}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 9}, \:{remainder = 1}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{quotient = 9}, \:{remainder ={11}}\right]}\right] (33)
Type: List(Record(quotient: Integer,remainder: Integer))

be sufficient? The argument t is implicitly given through the list structure. And why not even just compute the following?

fricas
L3 := map (t +-> divide (10*t,21).remainder, expand (1..21-1))

\label{eq34}\left[{10}, \:{20}, \: 9, \:{19}, \: 8, \:{18}, \: 7, \:{17}, \: 6, \:{16}, \: 5, \:{15}, \: 4, \:{14}, \: 3, \:{13}, \: 2, \:{12}, \: 1, \:{11}\right](34)
Type: List(Integer)

And as for )set message any off is good (no confusion) and bad (no hint what one could do with the expression).

Of corse I can do
fricas
position (t +-> t.remainder=1, map (t +-> divide (10*t, 21), expand  (1..20)))

\label{eq35}19(35)
Type: PositiveInteger?

But (I believe) it's nearer the mathematical way to write

select (t +-> t.2.remainder=1, map (t +-> t,divide (10<em>t, 21), expand (1..20)))

So I find all the solutions, and I remain the initial value which is right. It's as F = \{ t \in E \mid P(t) [is\ right]\}. Hier P(t)=t.2.remainder=1

Axiom believes that List are (almost) only in E^n,

With other CAS I use list as cartesian product of sets. It's very usefull and pretty to read.

With axiom I must use Record. If I use List I must explain that type I read (Record...) isn't type I have (Any...). It's to complex !

With record the length is fixed, and use of Record... is less pretty than use of List...

So I prefer that axiom-interpreter translates without question Any type to his own type. Even if there are difficults aroud this map : The first t is a Polynomial or an Integer ?

fricas
map (t +-> [t, X^t-1], expand (0..10))

\label{eq36}\begin{array}{@{}l}
\displaystyle
\left[{\left[ 0, \: 0 \right]}, \:{\left[ 1, \:{X - 1}\right]}, \:{\left[ 2, \:{{{X}^{2}}- 1}\right]}, \:{\left[ 3, \:{{{X}^{3}}- 1}\right]}, \:{\left[ 4, \:{{{X}^{4}}- 1}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[ 5, \:{{{X}^{5}}- 1}\right]}, \:{\left[ 6, \:{{{X}^{6}}- 1}\right]}, \:{\left[ 7, \:{{{X}^{7}}- 1}\right]}, \:{\left[ 8, \:{{{X}^{8}}- 1}\right]}, \:{\left[ 9, \:{{{X}^{9}}- 1}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{10}, \:{{{X}^{10}}- 1}\right]}\right] 
(36)
Type: List(List(Fraction(Polynomial(Integer))))

FMy?

Don't you think that in F = \{ t \in E \mid P(t)\} it depends on what your E is?

If you think that E is the set \{1,2,\ldots, 20\} then something like

fricas
)clear all
All user variables and function definitions have been cleared. [t for e in 1..20 | (t:=divide(10*e,21); one?(t.remainder))]

\label{eq37}\left[{\left[{quotient = 9}, \:{remainder = 1}\right]}\right](37)
Type: List(Record(quotient: Integer,remainder: Integer))

looks quite mathematical, n'est pas? Well, there is a local assignment to t, but it's short enough.

If you like your way more than perhaps write

fricas
K := [divide(10*t,21) for t in 1..20];
Type: List(Record(quotient: Integer,remainder: Integer))
fricas
[t for t in K | t.remainder=1]

\label{eq38}\left[{\left[{quotient = 9}, \:{remainder = 1}\right]}\right](38)
Type: List(Record(quotient: Integer,remainder: Integer))

And, by the way, if it weren't for the fact that divide in Aldor's libalgebra library has signature:

  divide: (%, %) -> (%, %);

instead of Axiom's:

  divide: (%,%) -> Record(quotient:%,remainder:%)

The above construction would also work in Aldor. (The use of select is not possible since it is a reserved keyword in Aldor.)

Ralf

providing specific types vs. duck-typing --Bill Page, Tue, 21 Mar 2006 06:04:51 -0600 reply
FMy?,

I think you meant to write:

fricas
select(t+->t.remainder=1,map (t +-> divide (10*t, 21), expand  (1..20)))

\label{eq39}\left[{\left[{quotient = 9}, \:{remainder = 1}\right]}\right](39)
Type: List(Record(quotient: Integer,remainder: Integer))

There is no meaning for t.2

I disagree that one should use a list as cartesian product of sets. This is very much against the strong-type design of Axiom. Instead Axom should provide a type equivalent to the cartesian product and it should be (nearly) as flexible as Lists. The next best thing that Axiom has is Record.

When creating an anonymous function you can provide specific types:

fricas
L:=map ((t:INT):Record(t:INT,p:POLY INT) +-> [t, X^t-1], expand (0..10))

\label{eq40}\begin{array}{@{}l}
\displaystyle
\left[{\left[{t = 0}, \:{p = 0}\right]}, \:{\left[{t = 1}, \:{p ={X - 1}}\right]}, \:{\left[{t = 2}, \:{p ={{{X}^{2}}- 1}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{t = 3}, \:{p ={{{X}^{3}}- 1}}\right]}, \:{\left[{t = 4}, \:{p ={{{X}^{4}}- 1}}\right]}, \:{\left[{t = 5}, \:{p ={{{X}^{5}}- 1}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{t = 6}, \:{p ={{{X}^{6}}- 1}}\right]}, \:{\left[{t = 7}, \:{p ={{{X}^{7}}- 1}}\right]}, \:{\left[{t = 8}, \:{p ={{{X}^{8}}- 1}}\right]}, \: \right.
\
\
\displaystyle
\left.{\left[{t = 9}, \:{p ={{{X}^{9}}- 1}}\right]}, \:{\left[{t ={10}}, \:{p ={{{X}^{10}}- 1}}\right]}\right] 
(40)
Type: List(Record(t: Integer,p: Polynomial(Integer)))

so that the result is clear.

The discussion of Lists, Tuples, Products and Records in Axiom is an old one. See:

I agree that Axiom does not get this right. In Aldor the Product type is generalized to Cross.

I do not know yet how to understand the domain Any but I think it is very interesting. It is probably very close to what is called "duck typing" in modern terms:

http://en.wikipedia.org/wiki/Duck_typing

This a form of dynamic typing where the values from the domain Any carry with them their actual types. To me this seems like a "partially successful" early experiment with this idea - Another remarkable first for the Axiom developers! But it is only partially sucessful because all of the implications about how it should interact with the rest of the static strongly-typed language of Axiom is not fully worked out.

showTypeInOutput --Bill Page, Thu, 05 Apr 2007 11:11:55 -0500 reply
The switch showTypeInOutput can be used to show the underlying type of an object of type Any.
fricas
)set message any off
showTypeInOutput true

\label{eq41}\mbox{\tt "Type of object will be displayed in output of a member of Any"}(41)
Type: String

Test

fricas
a:Any:=[1,"a"]

\label{eq42}{\left[{1 : \hbox{\axiomType{PositiveInteger}\ }}, \:{\mbox{\tt "a"}: \hbox{\axiomType{String}\ }}\right]}: \hbox{\axiomType{List}\ } (\hbox{\axiomType{Any}\ })(42)
Type: Any
fricas
a.1

\label{eq43}1 : \hbox{\axiomType{PositiveInteger}\ }(43)
Type: Any
fricas
(a.1)::Integer

\label{eq44}1(44)
Type: Integer
fricas
(a.2)::String

\label{eq45}\mbox{\tt "a"}(45)
Type: String




  Subject: (replying)   Be Bold !!
  ( 14 subscribers )  
Please rate this page: