[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Axiom-developer] Questions
From: |
David MENTRE |
Subject: |
Re: [Axiom-developer] Questions |
Date: |
Mon, 05 Jan 2004 21:20:17 +0100 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) Emacs/21.2 (gnu/linux) |
Stefan Dirnstorfer <address@hidden> writes:
> 2) The next one might just be a problem of recursive function
> definition. How else should it be done?
>
> (1) -> fac:= x+-> if x=0 then 1 else fac(x-1)
> (10)
> x
> +->
> if x= 0
> then 1
> else fac(x - 1)
> Type:
> AnonymousFunction
> (2) -> fac 1
> >> System error:
> Bind stack overflow.
> protected-symbol-warn called with (NIL)
You should use following syntax:
(1) -> fac n == if n = 0 then 1 else n * fac(n-1)
Type: Void
(2) -> fac 1
Compiling function fac with type Integer -> Integer
Compiling function fac as a recurrence relation.
(2) 1
Type: PositiveInteger
(3) -> fac 10
(3) 3628800
In your above definition (fac:= x+-> if x=0 then 1 else fac(x-1)), I
think you define a _variable_ that _contains an _anonymous_
function. Apparently this function is unknown to Axiom when it looks for
the recursive call.
Yours,
d.
--
David MENTRE <address@hidden> -- http://www.nongnu.org/axiom/