Group Abstract Group Abstract

Message Boards Message Boards

0
|
1.1K Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Convert a list to valid restrictions with the Wolfram Language?

Posted 10 years ago

I got a list like this

list={cond1,cond2,...}

, and I want to convert it to

cond1&&cond2&&...

How can I do that? I tried using

Do[
  constrains = And[list[[i]]]
  , {i, Length[list]}
  ];

But it doesn't work, it's constantly evaluating the And[ ].

POSTED BY: Andy Palmero

It's the command Apply, with its shortcut @@:

And@@{cond1,cond2,...}

Structurally, Apply[f,g[x1,x2,...]] removes g and replaces it with f. In our case, List[cond1, cond2, ...] becomes And[cond1, cond2, ...].

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard