Re: Return in function
- To: mathgroup at smc.vnet.net
- Subject: [mg105652] Re: Return in function
- From: "Nasser M. Abbasi" <nma at 12000.org>
- Date: Mon, 14 Dec 2009 00:04:46 -0500 (EST)
- References: <200912111146.GAA12933@smc.vnet.net> <hg00gb$jc1$1@smc.vnet.net> <hg2d7s$j8a$1@smc.vnet.net>
"David Bailey" <dave at removedbailey.co.uk> wrote in message news:hg2d7s$j8a$1 at 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 > Not only that, but if someone can write code in any language such as the output is "unpredictable" then there is something really wrong in this picture. No one should be able to write code in a well defined language such that the output becomes "unpredictable". We are not dealing with the heisenberg uncertainty principle here. May be the code is hard to understand, ok, but "unpredictable"? --Nasser
- References:
- Return in function
- From: dh <dh@metrohm.com>
- Return in function