little recursion yields stack-overflow



At Wed, 13 May 2009 19:48:50 +0100,
Oliver Kullmann wrote:
> ...
>
> I guess that's Ecl-related, but I couldn't find any information, and so
> I thought I ask here first. For the record, here's the function definition:
> 
> arithprog_ohg(k,n) := block([V : create_list(i,i,1,n), VS],
>   VS : setify(V),
>   if elementp(k,{0,1,2}) then return([V,listify(powerset(VS,k))]) 
>   elseif n < k or k < 0 then return([V,[]]) 
>   elseif k = n then return([V,[VS]]) else
>   return([V, 
>     append(arithprog_ohg(k,n-1)[2], 
>            create_list(setify(
>              create_list(n-d*i,i,0,k-1)), 
>                d,1,floor((n-1)/(k-1))))]))$
>
> P.S. Sure, one can eliminate the recursion here, but I don't use Lisp
> and Maxima in order to care about such details (it should be easier
> than to write a C-program, not harder).

I tried it on SBCL and arithprog_ohg(7,1000) is OK.

-- 
Yours sincerely,
Alexey Beshenov <al at cadadr.org>