5

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?

Jerry Guern
  • 4,602
  • 18
  • 47
M6299
  • 1,471
  • 1
  • 13
  • 20

1 Answers1

9

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?

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
  • Why is this question different and wasn't closed already? :) – Kuba Aug 05 '13 at 07:31
  • @Kuba different from what? – Mr.Wizard Aug 05 '13 at 07: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 05 '13 at 08:02
  • 2
    @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 05 '13 at 08: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 05 '13 at 08:24