MathGroup Archive 2002

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

Search the Archive

Re: Pure recursive functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg38378] Re: [mg38341] Pure recursive functions
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Fri, 13 Dec 2002 04:09:39 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Just one more thing. Your original idea works if you use Block instead 
of With:

In[61]:=
Block[{fact = Function[n, If[n == 0, 1, n fact[n - 1]]]}, fact[5]]


Out[61]=
120

Andrzej Kozlowski
Yokohama, Japan
http://www.mimuw.edu.pl/~akoz/
http://platon.c.u-tokyo.ac.jp/andrzej/


On Friday, December 13, 2002, at 12:05 AM, Andrzej Kozlowski wrote:

> Well, the only thing that comes to my mind is to use replace # by Slot:
>
> Function[If[Slot[1] == 0, 1, Slot[1] Slot[0][Slot[1] - 1]]]
>
> Is that any better?
>
> With best regards
>
> Andrzej
>
>
>
>
> On Thursday, December 12, 2002, at 11:43 PM, Niall Palfreyman wrote:
>
>> Andrzej Kozlowski schrieb:
>>
>>> Function[If[#1 == 0, 1, #1 #0[#1 - 1]]]
>>
>> Thanks very much for the tip. And as always with such questions, as 
>> soon
>> as you answer it, I notice that I asked the wrong question. What I 
>> still
>> would like to know is whether I can specify local names for these
>> arguments (using With[] or somesuch), since I'm creating a worksheet 
>> for
>> students, and the # arguments are a little hard to read. Any ideas?
>>
>> Best wishes,
>> Niall.<niall.palfreyman.vcf>
> Andrzej Kozlowski
> Yokohama, Japan
> http://www.mimuw.edu.pl/~akoz/
> http://platon.c.u-tokyo.ac.jp/andrzej/
>
>



  • Prev by Date: looking for a "test[ 1, ALL ]
  • Next by Date: Re: Pure recursive functions
  • Previous by thread: Pure recursive functions
  • Next by thread: Re: Pure recursive functions