Re: Re: Which, If and "neither True nor False"
- To: mathgroup at smc.vnet.net
- Subject: [mg9851] Re: [mg9728] Re: Which, If and "neither True nor False"
- From: Allan Hayes <hay at haystack.demon.co.uk>
- Date: Fri, 28 Nov 1997 05:36:06 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Paul E Howland wrote: > ....... > The most comprehensive implementation of Which (suggested in email to me > by Robert Villegas of WRI ) would be to have a construct of the form: > Which[test1, {action if True, action if Indeterminate}, > test2, {action if True, action if Indeterminate}, > ... > True, default action > ]; > which allows you to define an action to be carried out if a test returns > Indeterminate. This action could be to continue to the next test. Paul: How about the following? SetAttributes[Which2}, HoldAll]; Which2[c_, skp, skp, r__]:= Which2[r] Which2[c_, skp, u_, r__]:= If[c, Which2[r], Which2[r], u] Which2[c_, t_,skp, r__]:= If[c, t, Which2[r], Which2[r]] Which2[c_, t_, u_, r__]:= If[c, t, Which2[r], u]; Which2[d_]:= d skp is the action of skipping to the next test. Allan Allan Hayes Mathematica Training and Consulting Leicester, UK hay at haystack.demon.co.uk http://www.haystack.demon.co.uk voice: +44 (0)116 271 4198 fax: +44 (0)116 271 4198