2
$\begingroup$

I have a list of expressions and I need to apply AND on all the items.

Input: {xP == 1+x , yP == 3+y}

Desired output: xP == 1+x && yP == 3+y

I tried the following but it does not work.

Replace[{xp==1 + x , yp==3 + y}, "," -> "&&"]
$\endgroup$
3
  • 8
    $\begingroup$ And @@ {xP == 1 + x, yP == 3 + y} . From the docs, look up Apply. $\endgroup$
    – Syed
    May 9 at 15:49
  • $\begingroup$ @Syed thanks that's right $\endgroup$
    – Azzurro94
    May 9 at 15:56
  • 3
    $\begingroup$ Just for fun Distribute[{xP == 1+x , yP == 3+y}, List,List,Sequence,And] $\endgroup$
    – user1066
    May 9 at 17:58

3 Answers 3

5
$\begingroup$

Try And @@ {xP == 1 + x, yP == 3 + y} which is short for Apply[And, {xP == 1 + x, yP == 3 + y}]

$\endgroup$
3
$\begingroup$

Another way:

Reduce[{xP == 1 + x, yP == 3 + y}, {xP, yP}]
(*xP == 1 + x && yP == 3 + y*)
$\endgroup$
2
$\begingroup$
And @@ {xP == 1 + x, yP == 3 + y} 
xP == 1 + x && yP == 3 + y
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.