Walk a directory/Non-recursively: Difference between revisions

m
No edit summary
m (→‎{{header|Wren}}: Minor tidy)
 
(2 intermediate revisions by 2 users not shown)
Line 750:
 
=={{header|Elena}}==
ELENA 46.0x:
<syntaxhighlight lang="elena">import system'io;
import system'routines;
Line 759:
var dir := Directory.assign("c:\MyDir");
dir.getFiles("a.*").forEach:(printingLn);
}</syntaxhighlight>
 
Line 1,814:
Finished
 
</pre>
 
=={{header|RPL}}==
{{works with|Halcyon Calc|4.2.7}}
The very first instruction of this program <code>VARS</code> returns the list of all current files and subdirectories. The rest of the code retains the names that comply with the pattern given in input, and which are not directories. To do so, the program attempts to recall the contents of each object on the stack through <code>RCL</code>: if an error occurs, the object is then a directory and shall not be processed further.
≪ VARS → filter list
≪ { } 1 list SIZE '''FOR''' j
list j GET
'''IFERR''' DUP RCL '''THEN''' DROP2
'''ELSE'''
DROP →STR 2 OVER SIZE 1 - SUB
'''IF''' DUP filter POS '''THEN''' + ELSE DROP '''END'''
'''END'''
'''NEXT'''
≫ ≫
'WKDIR' STO
 
"T" WKDIR
{{out}}
<pre>
1: { "T" "TESTPGM" "FACTN" }
</pre>
 
Line 2,086 ⟶ 2,107:
=={{header|Wren}}==
{{libheader|Wren-pattern}}
<syntaxhighlight lang="ecmascriptwren">import "io" for Directory
import "./pattern" for Pattern
 
var walk = Fn.new { |dir, pattern|
9,485

edits