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.

The following code returns the first three integer elements of Sqrt[Range[100]]:

Cases[Sqrt[Range[100]], _Integer, 2, 3]
{1, 2, 3}

The following code looks like the preceding code but returns a different result:

Cases[Sqrt[Range[100]], _Integer, {2}, 3]
{2, 3, 5}

As we can see in the following picture, the argument {2} is not documented (it has no braces in the documentation):

enter image description here

What does the second code with {2} instead of 2 mean?

share|improve this question
4  
see documentation carefully it is there. –  Rorschach Aug 3 '13 at 6:25
add comment

closed as off-topic by Kuba, m_goldberg, Artes, Oleksandr R., Yves Klett Aug 5 '13 at 13:19

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

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Kuba, m_goldberg, Artes, Oleksandr R., Yves Klett
If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

up vote 6 down vote accepted

Actually this is documented; you need to look under More Information or Details and Options:

enter image description here

Further, you should realize that levelspec has special meaning in that is it describes a format that is common to a number of functions. Levelspec is described in:

See also: Levels: how do they work?

share|improve this answer
    
Why is this question different and wasn't closed already? :) –  Kuba Aug 5 '13 at 7:31
    
@Kuba different from what? –  Mr.Wizard Aug 5 '13 at 7:53
    
From others which answer is in Details and Options. Obviously (upvotes) this answer is helpful for community but isn't it an example of question which shoud be closed in order to keep repository transparent? Well, I know "should" is not a good word, if there are votes to close it will be. Maybe I should ask: "isn't the policy of SE to close such questions?" –  Kuba Aug 5 '13 at 8:02
1  
@Kuba I don't understand "keep repository transparent." As far as "SE policy" there is none for such a case; we have added simple mistake / easily found as a custom close reason, but that does not IMHO mean that all questions which are answered by the documentation need to be closed. The documentation isn't always easy to navigate and I hope that this answer serves to group information relating to levelspec in a useful fashion. –  Mr.Wizard Aug 5 '13 at 8:06
    
I agree than not all need to be closed, but in this case, the answer is almost on top. I do not demand anything, I have also not reason to doubt in your intentions, I just wanted to ask to avoid working against community by voting to close. By "keep repository transparent." I meant, we can rewrite documentation here be such database would be not handy. It is also due to search engine but it is a long story... :) ("Levels: how do...", shoud be easily found by typing "levels" etc. but it isn't due to ":" in the title, check title:levels: is:question and title:levels is:question) –  Kuba Aug 5 '13 at 8:24
add comment

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