Re: Help with concatenating a list with &&
- To: mathgroup at smc.vnet.net
- Subject: [mg102211] Re: Help with concatenating a list with &&
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Sat, 1 Aug 2009 04:01:46 -0400 (EDT)
- References: <h4uet9$inv$1@smc.vnet.net>
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
you need to understand that && is just a short form that is convenient
in many cases, but actually is just converted to And, as you can see
from this:
a && b // FullForm
if you search the documentation for && you are also directed to the page
for And.
Now And has the big advantage that it behaves like any other
symbol/function and you can do just:
And @@ ls
to receive what you want. I think it is one of the most important things
to learn about mathematica that everything is internally handled as
FullForm, so you might want to read about it, and of course also
tutorial/EverythingIsAnExpression ...
hth,
albert