MathGroup Archive 2009

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

Search the Archive

Re: Return in function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105641] Re: Return in function
  • From: David Bailey <dave at removedbailey.co.uk>
  • Date: Sun, 13 Dec 2009 05:38:13 -0500 (EST)
  • References: <200912111146.GAA12933@smc.vnet.net> <hg00gb$jc1$1@smc.vnet.net>

DrMajorBob wrote:
> Return doesn't work as documented, but that's not the best reason to never  
> use it.
> 
> Your three examples should have been written as
> 
> If[# == 2, a, #] & /@ {1, 2, 3}
> 
> {1, a, 3}
> 
> Function[x, If[x == 2, a, x]] /@ {1, 2, 3}
> 
> {1, a, 3}
> 
> f[x_] := If[x == 2, a, x]
> f /@ {1, 2, 3}
> 
> {1, a, 3}
> 
> Tortured constructions give unpredictable results, as a matter of simple  
> justice.
> 
> Bobby
> 

Aren't you being a bit unfair, Daniel has obviously taken time to thin 
out this example from whatever complicated context he found it in 
originally - minimal examples of problems often don't make sense:)

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: creating problem sets using mathematica
  • Next by Date: Toolbar
  • Previous by thread: Re: Return in function
  • Next by thread: Re: Re: Return in function