Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Trying to delete small elements from a list with

copy = DeleteCases[copy, {y_} /; y <= 1500.0 ] 

but it does not work.

share|improve this question

closed as off-topic by Kuba, bobthechemist, Artes, RunnyKine, belisarius May 23 '14 at 17:13

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – Kuba, bobthechemist, Artes, RunnyKine
If this question can be reworded to fit the rules in the help center, please edit the question.

Is your data actually a list of single element lists? That's what your code addresses... –  ciao May 23 '14 at 11:22
Welcome to mathematica.stackexchange.com! It's hard to answer you question unless you provide info on how copy looks. However, you might try DeleteCases[copy, y_ /; y <= 1500.0]. –  Akater May 23 '14 at 11:24
What rasher is saying is: The default value for levelspec in DeleteCases is {1}. –  Kuba May 23 '14 at 11:31

1 Answer 1

I'm guessing that your code didn't work because you have a list of approximate numbers, like so,

SeedRandom[1]; data = RandomReal[2000., 5]
{1634.78, 222.839, 1579.05, 375.606, 482.722}

and not a list of form {{1634.78}, {222.839}, ..., {482.722}}. Presuming that I've guessed right, there are two straight-forward ways to remove the numbers less than 1500.

DeleteCases[data, x_ /; x <= 1500.]
Select[data, # > 1500. &]

Both will return

{1634.78, 1579.05}

I would use Select.

share|improve this answer

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