Ralf Hemmecke wrote:
>
> >> product: (A,B) -> %
>
> > I did not propose change to 'product' because we already have
> > 'product' functions with somewhat different meaning. This
> > could confuse users. But maybe users can sort it out...
>
> I don't care to confuse a few users now. It should be done nicely. Look
> at all these cryptic function names that Maple still carries around. We
> should rather think of a good convention.
>
> If it were Aldor, I would have suggested
>
> bracket: (A, B) -> %
>
> so that one would later be able to say
>
> [a,b]
>
> in order to construct a product. Oh, maybe "construct" is used for this
> kind of sugar in FriCAS. I just don't know how much the interpreter will
> insist to turn [a,b] into List(Any) instead of Product(A,B).
>
> Anyway, however this constructor function will be called, we need some
> kind of convention. I say this, because also in the Aldor library I've
> seen constructors with [..] and also table(...), array(...).
> It should be easily guessable by a user.
I am not sure you can keep constructors calls completely uniform:
we have 'construct', 'new' and a bunch of more specific constructors.
Below is patch that I propose (only to Product, algebra will also
need some adjustment). With the patch I can do:
(3) -> Pr := Product(Integer, Polynomial(Integer))
(3) Product(Integer,Polynomial(Integer))
Type: Type
(4) -> [1, x]
(4) [1,x]
Type: List(Polynomial(Integer))
(5) -> [1, x]$Pr
(5) (1,x)
Type: Product(Integer,Polynomial(Integer))
(6) -> p1 := [1, x]$Pr
(6) (1,x)
Type: Product(Integer,Polynomial(Integer))
(7) -> p2 := [7, y]$Pr
(7) (7,y)
Type: Product(Integer,Polynomial(Integer))
(8) -> p1 + p2
(8) (8,y + x)
Type: Product(Integer,Polynomial(Integer))
(9) -> p1*p2
(9) (7,x y)
Type: Product(Integer,Polynomial(Integer))
Note that plain '[1, x]' produces a list -- one needs '$Pr' to choose
'construct' from the product.
--- ../ax-build52/src/algebra/PRODUCT.spad 2011-10-17 04:46:15.000000000
-0400
+++ PRODUCT.spad 2011-10-27 12:31:19.000000000 -0400
@@ -15,12 +15,13 @@
then OrderedAbelianMonoidSup
if A has OrderedSet and B has OrderedSet then OrderedSet
- makeprod : (A,B) -> %
- ++ makeprod(a,b) \undocumented
- selectfirst : % -> A
- ++ selectfirst(x) \undocumented
- selectsecond : % -> B
- ++ selectsecond(x) \undocumented
+ construct : (A,B) -> %
+ ++ construct(a,b) creates element of the product with
+ ++ components a and b.
+ first : % -> A
+ ++ first(x) selects first component of the product
+ second : % -> B
+ ++ second(x) selects second component of the product
T == add
@@ -41,11 +42,11 @@
x=y ==
x.acomp = y.acomp => x.bcomp = y.bcomp
false
- makeprod(a:A,b:B) :% == [a,b]
+ construct(a:A,b:B) :% == [a,b]$Rep
- selectfirst(x:%) : A == x.acomp
+ first(x:%) : A == x.acomp
- selectsecond (x:%) : B == x.bcomp
+ second (x:%) : B == x.bcomp
if A has Monoid and B has Monoid then
1 == [1$A,1$B]
--
Waldek Hebisch
[email protected]
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en.