Re: Re: Return in function
- To: mathgroup at smc.vnet.net
- Subject: [mg105661] Re: [mg105641] Re: Return in function
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Mon, 14 Dec 2009 00:06:27 -0500 (EST)
- References: <200912111146.GAA12933@smc.vnet.net> <hg00gb$jc1$1@smc.vnet.net>
- Reply-to: drmajorbob at yahoo.com
Using Return encourages spaghetti and procedural code habits, and it doesn't perform as advertised ANYWAY. So don't use it. Bobby On Sun, 13 Dec 2009 04:38:13 -0600, David Bailey <dave at removedbailey.co.uk> wrote: > 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 > -- DrMajorBob at yahoo.com
- References:
- Return in function
- From: dh <dh@metrohm.com>
- Return in function