Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

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

Search the Archive

Re: Double evaluation in recursive function

  • To: mathgroup at
  • Subject: [mg19565] Re: Double evaluation in recursive function
  • From: David Bailey <db at>
  • Date: Wed, 1 Sep 1999 23:07:01 -0400
  • Organization: Salford Software
  • References: <7q9h2j$>
  • Sender: owner-wri-mathgroup at

On 28 Aug 1999 16:33:23 -0400, "Benoit Debaque"
<bdebaque at> wrote:

>Hi all !
>Does somebody know how to use 2 calls at a time in a recursive function...?
>for example I want to evaluate the following
>myf[x_] : =  If[ x > 5, i = x ; j = x ; i--; j--; myf[i]; myf[j] ]
>I get the answer from
>apparently Mathematica doesn't like much the second term myf[j], because it
>start from 5 to 5 ! and not from 6 to 5 like variable can I
>manage such a problem ?

It is not entirely clear what this code is meant to do, since your
'If' construction does not specify the result for x <= 5, however, one
obvious problem is that i and j are global variables so the value of j
will have been destroyed before the second call is executed. So write
        <something should go here or function will return Null>

You could probably eliminate i and j by simply calling myf[x-1] - but
it is a bit difficult to figure out what this code was designed to do.

David Bailey
Salford Software

  • Prev by Date: Re: Asking you how to...
  • Next by Date: Re: Avoid out of memory in Simplify
  • Previous by thread: Re: Avoid out of memory in Simplify
  • Next by thread: Re: Re: Double evaluation in recursive function