Jump to content

Walk a directory/Non-recursively: Difference between revisions

Added Wren
(Added 11l)
(Added Wren)
Line 1,869:
Console.WriteLine(file)
Next</lang>
 
=={{header|Wren}}==
{{libheader|Wren-pattern}}
<lang ecmascript>import "io" for Directory
import "/pattern" for Pattern
 
var walk = Fn.new { |dir, pattern|
if (!Directory.exists(dir)) Fiber.abort("Directory does not exist.")
var files = Directory.list(dir)
return files.where { |f| pattern.isMatch(f) }
}
 
// get all C header files beginning with 'a' or 'b'
var p = Pattern.new("[a|b]+0^..h", Pattern.whole)
for (f in walk.call("/usr/include", p)) System.print(f)</lang>
 
{{out}}
<pre>
aio.h
aliases.h
alloca.h
ar.h
argp.h
argz.h
asoundlib.h
assert.h
byteswap.h
</pre>
 
=={{header|zkl}}==
9,490

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.