Re: Help with concatenating a list with &&

• To: mathgroup at smc.vnet.net
• Subject: [mg102193] Re: [mg102153] Help with concatenating a list with &&
• From: Murray Eisenberg <murray at math.umass.edu>
• Date: Sat, 1 Aug 2009 03:58:07 -0400 (EDT)
• Organization: Mathematics & Statistics, Univ. of Mass./Amherst
• References: <200907310952.FAA19208@smc.vnet.net>

```    And @@ {ex1, ex2, ex3, ex4}
ex1&&ex2&&ex3&&ex4

In general, beware of using "special input forms" (such as && instead of
the actual function And) in combination with functional constructs (such
as Apply).

janey wrote:
> Can anyone help me make better use of mathematica's built in commands?
>
> My problem is to take the list of expressions ls:
>
> ls={ex1, ex2, ex3, ex4}
>
> and connect them to obtain
>
> ex1 && ex2 && ex3 && ex4
>
>
> I thought I should be able to use
>
> && @@ ls
>
> or equivalently Apply[&&, ls]
>
> However this fails. I ended up using the very awkward
>
> conditions = ls[[1]] && ls[[2]]
> Do[conds = conds && ls[[i]], {i, 3, Length[ls]}]
>
> which works but feels like just bludgeoning the problem
>
> Does anyone know of a more elegant way to work this?
>
> Thanks,
> Jane.
>

--
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

```

• Prev by Date: Re: Finding the Position of Elements in a List that Contain
• Next by Date: Re: Finding the Position of Elements in a List that
• Previous by thread: Re: Help with concatenating a list with &&
• Next by thread: Re: Help with concatenating a list with &&