[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-developer] [#187 trouoble with tuples] work around suggestion (if
[Axiom-developer] [#187 trouoble with tuples] work around suggestion (if you must use Tuple)
Fri, 01 Jul 2005 06:16:19 -0500
From: William Sit, July 1, 2005 06:26:00 -5:00<br>
The following works (not as neat as it should be, of course)
f2(x,y)==x*y -- fixed typo
f3:Tuple INT -> INT
f3(x) == reduce(*,[select(x,i::NNI) for i in 0..length(x)-1])
f4:Tuple INT -> List INT
f4 x == concat(x::List INT, x::List INT)
Note that neither 'f3(1,2,3,4)' nor 'f3((1,2,3,4))' works, even though tuples
are lists without the square brackets, essentially. In both cases, the reason
is probably the parser treats the arities differently. Recall that the
Interpreter (and Axiom) treats parenthesis as "applied to" (so 'f3 (1,2,3,4)'
is the same as applying 'f3' to 4 distinct arguments and 'f3(a)' is 'f3 a'). I
do think the second form should have worked without the explicit coercion.
I do not know why in the design of 'Tuple S', the parts are not to be
referenced with just the usual list method like 'a.i' and must use 'select'.
Also the indexing in 'Tuple S' starts with 0. In the very old days of
Scratchpad, all aggregates indexing was zero based. Most are converted to
one-based and you can have a choice. Somehow, 'Tuple S' was not updated to
One final puzzle: What is the 'G1433' (or whatever) function from
'Integer->Boolean'? I tried
f3 x == reduce(*,[select(x,i::NNI) for i in 0..length(x)-1])
and there is no such function.
forwarded from http://page.axiom-developer.org/zope/mathaction/address@hidden
|[Prev in Thread]
||[Next in Thread]|
- [Axiom-developer] [#187 trouoble with tuples] work around suggestion (if you must use Tuple),