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:20:11 +0000

```Martin Rubey writes:
> 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)])
>  >

Now I got it:

f:EXPR INT -> EXPR INT
f(0)==1; f(1)==2;
f(n | number? n)==sum(f(i)*f(n-i), i=1..(n-1))
f(n | not number? n)==kernel(fop, [n])
fop := operator 'fop
evaluate(fop,f)

We declare the function to take expressions as arguments.  If the argument is a
number, go ahead.  Otherwise, return an unevaluated operator fop, which
evaluates to f...

I think that evaluating fop i does the following:

axiom looks for an %eval property of fop and finds f.
axiom applies f to i and returns kernel(fop, [i])

If we wrote

f(n | not number? n)==fop n

we produced an infinite loop...

Martin

```

reply via email to

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