# Re: A question about recursive programming

**URL:** <https://www.ruby-forum.com/t/re-a-question-about-recursive-programming/50052>\
**Category:** Ruby\
**Created:** [December 12, 2005, 4:45pm UTC](https://www.ruby-forum.com/t/re-a-question-about-recursive-programming/50052 "2005-12-12T16:45:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![KroegerS\_Simon\_Sext](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/57b2e6/32.png) [@KroegerS\_Simon\_Sext](https://www.ruby-forum.com/u/KroegerS_Simon_Sext)\
**Post date:** [December 12, 2005, 4:45pm UTC](https://www.ruby-forum.com/t/re-a-question-about-recursive-programming/50052/1 "2005-12-12T16:45:36Z")

</div>

> ```
> temp=arr.delete_at(arr.length-1)
> b=all_sum(arr)+all_sum(arr).collect{|i| i+temp}
> 
> ```
> 
> end
> 
> c=[1,2]  
> p all\_sum©
> 
> Error: in `all\_sum’: stack level too deep (SystemStackError)
> 
> Can anyone give me some advice?

Hmm,

the b= lines doesn’t make much sense, you may want to replace  
them with return statemants.

Note that delete\_at modifies the receiver - the original array  
(for this and all other recursions). So it won’t work even if  
you change the b= to return.

cheers

Simon
