sets and functions / interpreter bug when redefining *
Martin Rubey <[email protected]> 29 Oct 2007 14:39:13 +0100
| Newsgroups | gmane.comp.mathematics.axiom.general |
|---|---|
| Message-ID | <[email protected]> |
Francois Maltey <[email protected]> writes: > Dear Martin, > > > what does a looping construct have to do with a Cartesian product? > > The construct arround reduce/concat isn't so usual in order to > built several overlapped loops. > cartesian product and repeat keyword are two possibilities. > > > > The * isn't the better operator because this locks > > > {1,2,3} * {1,2,3} = {1,2,3,4,6,9} > > > and {1,2,3} + {1,2,3} = {2,3,4,5,6} > > > > I actually wondered already once, why "+" is not union$Set, "-" not > > difference$Set. I was thinking of Boolean algebra. Now, I looked a little closer to find the Category "Logic", which exports /\ and \/, which would in fact be a lot better than + and *. > I think that operator for sets are missing. > union (union (E, F), G) is less clever than E union F union G. (1) -> \/(a: Set INT, b: Set INT): Set INT == union(a, b) Function declaration ?\/? : (Set Integer,Set Integer) -> Set Integer has been added to workspace. (2) -> set [1,2,3] \/ set [2,3,4] Compiling function \/ with type (Set Integer,Set Integer) -> Set Integer (2) {1,2,3,4} Type: Set Integer > But why do you want a +. It might be possible to have more operators > than only +, -, *, /, ^, ::, $, # and @. yes, but I want to be use the "right" operators. As we know already (see Monoid / AbelianMonoid discussion), currently this is not always possible in Aldor or Axiom. But when it is, we should use them. Just to make sure, I did not say that your definition of * and + for sets is bad per se. I only found it unusual. And I do not want "unusual" things in the axiom library. The user should make this definitions himself. Unfortunately, there is a bug in the interpreter: (1) -> _*(A: Set INT, B: Set INT): Set INT == set concat [[(a*b)$Integer for a in members A] for b in members B] Function declaration ?*? : (Set Integer,Set Integer) -> Set Integer has been added to workspace. Type: Void (2) -> 2*3 Compiling function * with type (Set Integer,Set Integer) -> Set Integer Conversion failed in the compiled user function * . Cannot convert from type Integer to Set Integer for value 2 > axiom doesn't understand that sin+cos is the function x +-> (sin x + cos x) I do not see the connection to the topic above. But still, you can quite easily build a domain that has, for example, univariate functions as objects. That might indeed be useful. Martin