MathGroup Archive 2006

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

Search the Archive

Re: Re: "short circuiting" And and Or

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70669] Re: [mg70624] Re: "short circuiting" And and Or
  • From: "Chris Chiasson" <chris at chiasson.name>
  • Date: Sun, 22 Oct 2006 01:20:38 -0400 (EDT)
  • References: <eha5b7$b5b$1@smc.vnet.net> <200610210914.FAA29141@smc.vnet.net>

I did not know about the HoldAll attribute of And. Thank you.

On 10/21/06, David Bailey <dave at remove_thisdbailey.co.uk> wrote:
> Szabolcs Horvat wrote:
> > I'd like to write a function that tests whether there are any elements
> > in a list that violate a certain condition. I could simply use
> > And@@condition/@list, but for reasons of efficiency I'd like to stop
> > the testing as soon as a "False" value is found. Is there any elegant
> > way of doing this without writing an explicit While loop?
> >
> > Szabolcs Horvát
> >
> Hello,
>
> The following program illustrates that this is already the behaviour:
>
> f1[]:=(Print["f1"];False);
> f2[]:=(Print["f2"];False);
>
> f1[] && f2[]
>
> Notice that And has attribute HoldAll - so it can evaluate its arguments
> as required, and that it does not have attribute Orderless - so the
> arguments can't get permuted.
>
> David Bailey
> http://www.dbaileyconsultancy.co.uk
>
>
>
>
>
>


-- 
http://chris.chiasson.name/


  • Prev by Date: Re: Problem in loading packages in Mathematica
  • Next by Date: Re: Plot3D question
  • Previous by thread: Re: "short circuiting" And and Or
  • Next by thread: Re: "short circuiting" And and Or