perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carlos Kassab <...@glin.com.mx>
Subject Re: Recursivity with embperl
Date Wed, 22 Jan 2003 03:52:38 GMT
Hi:

Thank you for your help. it worked. Below is an example of a recursive
process:

But i still have a question, how can i do to print inside the procedure
get_factorial without call the subroutine eplprint?. If i try to use
embperl code to define the sub ([$ sub get factorial $]), it does not
work.

[$ sub eplprint $]
[-  $c = shift ; -]
[+ $c +]
[$ endsub $]


[*
sub get_factorial 
{
  local $a;
  $a = shift;

  if( $a == 1 )
  {
     &eplprint($a);
     return($a);
  } else {
     &eplprint($a);
     return($a*&get_factorial($a-1));
  }
}
*]

[- $d= 3; $b=&get_factorial($d);-]

 --- "Factorial" of [+ $d +] is [+ $b +]



Thank you 

Carlos Kassab





El mar, 21-01-2003 a las 00:59, Gerald Richter escribió:
> 
> >
> > it seems that embperl is loosing the values for recursive process.
> >
> > Do  you know a way to do recursive processes with embperl? i am using
> > embperl 1.3.4
> >
> 
> If you are using Embperl's [$ sub $] or Execute to do the recursive call you
> need to declare the variables local. In Embperl you can do this with
> 
> [*
> local $foo ;
> local $bar ;
> *]
> 
> Note that in 1.3.4 'my' instead of local does not work (in 2.0 it does)
> 
> Gerald
> 
> 
> -------------------------------------------------------------
> Gerald Richter    ecos electronic communication services gmbh
> Internetconnect * Webserver/-design/-datenbanken * Consulting
> 
> Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
> E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
> WWW:        http://www.ecos.de      Fax:      +49 6133 925152
> -------------------------------------------------------------
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message