RE: 'mysplit' ???

2012-11-26 Thread Tobias Hoellrich
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Greg 
Aiken
Sent: Monday, November 26, 2012 9:19 AM
To: Perl-Win32-Users@listserv.ActiveState.com
Subject: 'mysplit' ???

i just ran across a perl recursion example that i am trying to understand...

(url 
=http://www.shlomifish.org/lecture/Perl/Newbies/lecture2/functions/recursion.html)

sub mysplit
{
my ($total, $num_elems, @accum) = @_;

if ($num_elems == 1)
{
push @accum, $total;
print join(,, @accum), \n;

return;
}

for (my $item=0 ; $item = $total ; $item++)
{
my @new_accum = (@accum, $item);
mysplit($total-$item, $num_elems-1, @new_accum);   # 
'mysplit'
}
}
mysplit(10,3);

the line of code ive never seen before, and am struggling with to understand - 
is the following...

   mysplit($total-$item, $num_elems-1, @new_accum);

ive 'googled' the word 'mysplit' and find no results.

might anyone know exactly what 'mysplit' is?


Hi Greg - this is an example about recursions in perl. mysplit is the name of 
the sub you're currently in (look at the beginning where it says sub 
mysplit). The subroutine is calling itself.

Hope this helps - Tobias


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: 'mysplit' ???

2012-11-26 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Greg 
Aiken
Sent: 26 November 2012 16:19
To: Perl-Win32-Users@listserv.activestate.com
Subject: 'mysplit' ???

 i just ran across a perl recursion example that i am trying to understand...

 (url 
 =http://www.shlomifish.org/lecture/Perl/Newbies/lecture2/functions/recursion.html)

 sub mysplit
  ^^^
 {
my ($total, $num_elems, @accum) = @_;

if ($num_elems == 1)
{
push @accum, $total;
print join(,, @accum), \n;

return;
}

for (my $item=0 ; $item = $total ; $item++)
{
my @new_accum = (@accum, $item);
mysplit($total-$item, $num_elems-1, @new_accum);   # 
 'mysplit'
}
 }
 mysplit(10,3);

 the line of code ive never seen before, and am struggling with to understand 
 - is the following...

   mysplit($total-$item, $num_elems-1, @new_accum);

 ive 'googled' the word 'mysplit' and find no results.

 might anyone know exactly what 'mysplit' is?

I may have misunderstood your question, but mysplit is the sub defined above 
(see ^^^).

HTH


--
Brian Raven






Please consider the environment before printing this e-mail.

This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient or have received this e-mail in error, please advise 
the sender immediately by reply e-mail and delete this message and any 
attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: 'mysplit' ???

2012-11-26 Thread Greg Aiken
duh...  thanks tons!

On Mon, Nov 26, 2012 at 8:37 AM, Tobias Hoellrich thoel...@adobe.comwrote:

  *From:* perl-win32-users-boun...@listserv.activestate.com [
 mailto:perl-win32-users-boun...@listserv.activestate.comperl-win32-users-boun...@listserv.activestate.com]
 *On Behalf Of *Greg Aiken
 *Sent:* Monday, November 26, 2012 9:19 AM
 *To:* Perl-Win32-Users@listserv.ActiveState.com
 *Subject:* 'mysplit' ???

 i just ran across a perl recursion example that i am trying to
 understand...

 (url =*
 http://www.shlomifish.org/lecture/Perl/Newbies/lecture2/functions/recursion.html
 *http://www.shlomifish.org/lecture/Perl/Newbies/lecture2/functions/recursion.html
 )

 sub mysplit
 {
 my ($total, $num_elems, @accum) = @_;

 if ($num_elems == 1)
 {
 push @accum, $total;
 print join(,, @accum), \n;

 return;
 }

 for (my $item=0 ; $item = $total ; $item++)
 {
 my @new_accum = (@accum, $item);
 mysplit($total-$item, $num_elems-1, @new_accum);   #
 'mysplit'
 }
 }
 mysplit(10,3);

 the line of code ive never seen before, and am struggling with to
 understand - is the following...

mysplit($total-$item, $num_elems-1, @new_accum);

 ive 'googled' the word 'mysplit' and find no results.

 might anyone know exactly what 'mysplit' is?


 Hi Greg – this is an example about recursions in perl. “mysplit” is the
 name of the sub you’re currently in (look at the beginning where it says
 “sub mysplit”). The subroutine is calling itself.

 Hope this helps – Tobias



___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs