Hi William,
)set mess bot off -- no cheating
(1) variables (2*x+1/x)$DMP([x], EXPR INT)
)set mess bot off
(3) a:=(2*x + 1/x)$DMP([x], EXPR INT);
variables a
That are nice ones. One has to understand that for (1)
foo(arg)$DOM should be considered as syntactic sugar for
(foo$DOM)(arg). A space between foo and (arg) does not help to get a
different binding. It would even be disastrous if "foo(arg)" would be
different from "foo (arg)". Maybe that is the reason why function
application has one of the highest precedences in Aldor/Axiom.
Ralf
PS: Would you have guessed that the output of the following program is... ?
aldor -grun -laldor precedence.as
(foo bar id)(1) = 6
(foo(bar)(id))(1) = 35
(foo (bar) (id))(1) = 35
(foo (bar) id)(1) = 35
(foo bar (id))(1) = 6
---precedence.as
#include "aldor"
#include "aldorio"
Z ==> Integer;
Dom: with {
id: Z -> Z;
bar: (Z -> Z) -> (Z -> Z);
foo: (Z -> Z) -> (Z -> Z);
bar: Z -> Z;
foo: (Z -> Z) -> ((Z -> Z) -> (Z -> Z));
} == add {
id(z: Z): Z == z;
bar(f: Z -> Z)(z: Z): Z == 2*f(z);
foo(f: Z -> Z)(z: Z): Z == 3*f(z);
bar(z: Z): Z == 5*z;
foo(f: Z -> Z)(g: Z -> Z)(z: Z): Z == 7*f(g(z));
}
main(): () == {
import from Z, Dom;
f: Z -> Z := foo bar id;
stdout << "(foo bar id)(1) = " << f(1) << newline;
g: Z -> Z := foo(bar)(id);
stdout << "(foo(bar)(id))(1) = " << g(1) << newline;
h: Z -> Z := foo (bar) (id);
stdout << "(foo (bar) (id))(1) = " << h(1) << newline;
i: Z -> Z := foo (bar) id;
stdout << "(foo (bar) id)(1) = " << i(1) << newline;
j: Z -> Z := foo bar (id);
stdout << "(foo bar (id))(1) = " << j(1) << newline;
}
main();
_______________________________________________
Axiom-developer mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/axiom-developer