RaFaL Pocztarski wrote:

> Chris Spurgeon wrote:
>
> > (...) It strikes me that this
> > could have been more elegantly done with some sort of recursive function,
> > but I couldn't figure out how.  Any ideas?
>
> (...) And now, my suggestion:
>
> ----8<--------8<----
> #!/usr/bin/perl -w
>
> my $max=9;
>
> numbers($max+1);
> sub numbers{
>     my $d=shift;
>     if(--$d){ numbers($d,@_,$_) for (0,$d) }
>     else{ printsum(@_) }
> }
> sub printsum{
>     my $s;
>     $s+=$_ for @_;
>     print join('+',@_),"=$s\n";
> }
> ----8<--------8<----

I'm just curious if you've found my code useful, because you haven't
answered. 

- RaFaL Pocztarski, [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to