axiom-mail
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Axiom-mail] sum()


From: Martin Rubey
Subject: Re: [Axiom-mail] sum()
Date: Wed, 23 Jun 2004 12:01:57 +0000

Martin Rubey writes:
 > You tried: 
 > 
 >  >    f: Integer -> Integer;
 >  >    f(0)==1; f(1)==2;
 >  >    f(n)==sum(f(i)*f(n-i), i=0..(n-1))
 > 
 > Try
 > 
 > f: Integer -> Integer;               
 > f(0)==1; f(1)==2;                    
 > f(n)==reduce(+,[f(i)*f(n-i) for i in 1..(n-1)])
 > 
 > I have no good explanation why sum won't work. (Well, I know why it happens
 > internally. I'm looking for a solution...)

Unfortunately, the solution won't be easy. The problem in writing an operator
"sum" that does what you need is the following: It seems that in axiom all the
parameters of a function are evaluated first. Thus, the first thing the
interpreter sees when it tries to do calculate f(2) is

f(i)*f(n-i)

which is not defined, since we said that f is a function on the
integers. However, "i" is no an integer but a symbol here...

So what would be needed is a facility to tell axiom *not* to evaluate the
argument of some function. On the other hand, there might be other solutions
I'm unable to think of right now. We'll see.

Martin





reply via email to

[Prev in Thread] Current Thread [Next in Thread]