MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Reentrant Functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg29464] Re: [mg29424] Reentrant Functions
  • From: Adalbert Hanssen <hanssen at zeiss.de>
  • Date: Wed, 20 Jun 2001 04:36:47 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

>Hello,
>can functions be made reentrant, i.e. can I invoke in a function the 
>same function again?
>Hermann Schmitt

yes: consider e.g.

Ggt[a_,b_]:=If[a>b,Ggt[a-b,b],If[b>a,Ggt[b-a,a],a]]


Trace[Ggt[100,80],Ggt]  yields:

{Ggt[100, 80], 
  If[100 > 80, Ggt[100 - 80, 80], If[80 > 100, Ggt[80 - 100, 100], 100]], 
  Ggt[100 - 80, 80], Ggt[20, 80], 
  If[20 > 80, Ggt[20 - 80, 80], If[80 > 20, Ggt[80 - 20, 20], 20]], 
  Ggt[80 - 20, 20], Ggt[60, 20], 
  If[60 > 20, Ggt[60 - 20, 20], If[20 > 60, Ggt[20 - 60, 60], 60]], 
  Ggt[60 - 20, 20], Ggt[40, 20], 
  If[40 > 20, Ggt[40 - 20, 20], If[20 > 40, Ggt[20 - 40, 40], 40]], 
  Ggt[40 - 20, 20], Ggt[20, 20], 
  If[20 > 20, Ggt[20 - 20, 20], If[20 > 20, Ggt[20 - 20, 20], 20]]}

regards

Adalbert Hanszen




  • Prev by Date: Re: Reentrant Functions
  • Next by Date: RE: Rows
  • Previous by thread: Re: Reentrant Functions
  • Next by thread: Re: Reentrant Functions