24

Documentation discrepancy present in 10.3 and fixed in 10.4.1


According to the documentation for FileNames under Details:

FileNames[forms,dirs,{n}] includes names of directories only if they appear exactly at level n.

However when I attempt to use this syntax I get an error:

FileNames["foo*", "c:\\", {2}]

FileNames::innf: Non-negative integer or Infinity expected at position 3 in FileNames[foo*,c:\,{2}]. >>

I am using Mathematica 10.0.1 under Windows. Does this syntax work on other systems?

Kuba
  • 136,707
  • 13
  • 279
  • 740
Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
  • 18
    Maybe they have a documentation driven development at WRI. They first write the doc and then implement the stuff and some guy went home early :-) – halirutan Sep 24 '14 at 08:55
  • 1
    I have exactly the same error message with both MMA 10.0.1.0 and MMA 9.0.1.0, on OS X 10.9.4 (when I input for example FileNames["foo*", "/", {2}]) Also in MMA 9.0.1.0 Documentation, the curly brackets are missing : enter image description here – SquareOne Sep 24 '14 at 08:37
  • I might argue that this is a typographical error in the documentation. Removing the curly braces seems to work on v10 win7 and linux (for the few examples I've tried). – bobthechemist Sep 24 '14 at 13:20
  • @bobthechemist That (without the {}) is also a documented syntax meaning down to level n, and yes it does seem to work. The syntax in the question is supposed to mean "exactly at level n" as it says. – Mr.Wizard Sep 24 '14 at 13:41
  • @halirutan I don't know if you meant that as a joke or not, but I believe that does in fact happen, and perhaps is the case here. See: (54491). I am adding the bugs tag meaning documentation bug. – Mr.Wizard Sep 24 '14 at 13:42
  • @Mr.Wizard I missed that subtlety, although with 20-20 hindsight it is consistent with other functions with levelspec. I note that curly braces didn't work on linux v10. – bobthechemist Sep 24 '14 at 13:50
  • 1
    @Mr.Wizard It was meant only half as joke. I was referring to test-driven development which is similar only that you write unit tests for components that don't exist yet. Then you hit random keys until you come up with code that fulfills the test.. – halirutan Sep 24 '14 at 14:50
  • ?? FileNames also knows nothing about {n}. – Jinxed Feb 22 '15 at 09:42
  • @Kuba I don't believe that I have. Do it if you have time. – Mr.Wizard Feb 23 '15 at 03:35
  • 1
    @Mr.Wizard So I got a reply that is was already reported. – Kuba Mar 05 '15 at 19:03
  • 3
    Persistent in 10.2. – rcollyer Jul 15 '15 at 12:58
  • 1
    The behavior might persist, but as of my 10.1 (linux) the documentation does not show the {n} form.. – george2079 Jul 23 '15 at 19:15
  • @george2079 Oops! No, it's still there in the documentation section under Details. Re-editing the header. :^) – Mr.Wizard Jul 23 '15 at 19:58
  • so it is. Maybe you should put that ("under details" ) in the question. – george2079 Jul 23 '15 at 20:07
  • @george2079 I should have done that from the start; its absence confused both of us and who knows how many others. Corrected now. – Mr.Wizard Jul 23 '15 at 20:24
  • The bracketed form seems to work in 10.4, at least for me on Linux. – Malte Lenz Apr 21 '16 at 07:16
  • 1
    Seems to be correctly documented in Mathematica 10.4 windows edition. (also the markup with the {n} brackets seems to work, even though it is not documented anymore) – Frank Martin Aug 02 '16 at 15:11
  • @Frank I did not see your comment until now. Thank you. – Mr.Wizard Aug 09 '16 at 21:13

1 Answers1

2

It was fixed in 10.4.1

Posting this wiki answer to reduce the unanswered questions stack

FileNames["D*", $InstallationDirectory, {2}]
{"C:\\Program Files\\Wolfram Research\\Mathematica\\10.4\\SystemFiles\\Data", 
 "C:\\Program Files\\Wolfram Research\\Mathematica\\10.4\\SystemFiles\\Devices", 
 "C:\\Program Files\\Wolfram Research\\Mathematica\\10.4\\SystemFiles\\Dictionaries"}
Kuba
  • 136,707
  • 13
  • 279
  • 740