Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.9K Views
|
6 Replies
|
7 Total Likes
View groups...
Share
Share this post:

List-threading operations with logicals

Posted 11 years ago

{2,3,4}+3 delivers {5,6,7}

I'd like {2,3,4}==3 to deliver {False, True, False}, but it doesn't. Can I make it do that?

Jim Simons

POSTED BY: Jim Simons
6 Replies
POSTED BY: Marco Thiel
Posted 11 years ago

Thanks guys, but I've discovered a different, and IMHO better, answer:

Thread[{2,3,4}==3]

Jim

POSTED BY: Jim Simons

In[2]:= Thread[{2, 3, 4} == 3]

Out[2]= {False, True, False}

POSTED BY: Frank Kampas

Another possible way

lis = {2, 3, 4};
Outer[Equal, {3},lis] // Flatten
(* {False, True, False} *)
POSTED BY: Nasser M. Abbasi

I think that this might work:

(# == 3) & /@ {2, 3, 4}

It does appear to give the result you want.

M.

POSTED BY: Marco Thiel
Posted 11 years ago

Ah, I see Frank got there 5 seconds before me!!

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