Message Boards Message Boards

0
|
11334 Views
|
6 Replies
|
2 Total Likes
View groups...
Share
Share this post:
GROUPS:

Why does Select does not work with PrimeQ?

Posted 9 years ago

Hi,

Select[{1, 2, 6, 15, 37, 90, 218, 527, 1273, 3074}, EvenQ]

as well as

Select[{1, 2, 6, 15, 37, 90, 218, 527, 1273, 3074}, OddQ]

do work as expected.

Why does PrimeQ does not work the same way? Wolfram alpha link to sample

Hermann.

6 Replies

Well, Wolfram|Alpha is not Mathematica and in general, Mathematica syntax does not work with it. W|A has a natural language interface, which makes it possible to ask questions without learning a programming language. But it can also be very frustrating to get it to do what you want (at least I find it very frustrating and unpredictable).

Try telling it to

select primes from {1, 2, 6, 15, 37, 90, 218, 527, 1273, 3074}

Based on the interpretation of this natural language query above, I tried

Select[{1, 2, 6, 15, 37, 90, 218, 527, 1273, 3074}, PrimeQ[#1]&]

which also works.

POSTED BY: Szabolcs Horvát

I know Mathematica is free for Raspberry Pi, but is some "more Mathematica like" web interface than Wolfram/Alpha out there?

Yes, there is. Take a look at the Programming Cloud. It can be used with a free account, with some limitations. I haven't looked at it in detail as I do have access to desktop Mathematica, so I'm not sure how severe the limitations are, but on a first glance it appears to be a pretty complete Mathematica-in-the-cloud.

I don't fully understand how it differs from Mathematica Online (which has no free version so I never tried it). Here's a thread on that: http://community.wolfram.com/groups/-/m/t/344601

POSTED BY: Szabolcs Horvát
In[1]:= Select[{1, 2, 6, 15, 37, 90, 218, 527, 1273, 3074}, PrimeQ]

Out[1]= {2, 37}
POSTED BY: S M Blinder

Thanks for showing that it works in general.

What I stated is that it does not work in Wolfram Alpha link:

http://www.wolframalpha.com/input/?i=Select%5B%7B1,%202,%206,%2015,%2037,%2090,%20218,%20527,%201273,%203074%7D,%20PrimeQ%5D

While eg. OddQ does work in Wolram Alpha link:

http://www.wolframalpha.com/input/?i=Select%5B%7B1%2C+2%2C+6%2C+15%2C+37%2C+90%2C+218%2C+527%2C+1273%2C+3074%7D%2C+OddQ%5D

So is PrimeQ not working in Wolfram Alpha link a Wolfram Alpha bug?

Hermann.

Thank you, both terms work in Wolfram|Alpha.

And you are right, the natual language interpretation is strange sometimes as this link shows:

select primes from LinearRecurrence[{0,7,0,-7,0,1},{1,2,6,15,37,90},20]

Should have returned the same as your terms, but does something completely different.

I really like Wolfram|Alpha for two reasons:

  • its free
  • you can easily share link for an evaluation

I know Mathematica is free for Raspberry Pi, but is some "more Mathematica like" web interface than Wolfram/Alpha out there?

Hermann.

Thank you, programming cloud seems to be more Mathematica still providing much for hobby mathematics oeis.org related investigations! enter image description here

Hermann.

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

Group Abstract Group Abstract