Empty directory: Difference between revisions

(Added C# example)
Line 191:
 
 
=={{header|Perl 6}}==
<lang perl6>sub dir-is-empty ($d) { not dir $dir }</lang>
The <tt>dir</tt> function returns a lazy list of filenames, excluding "<tt>.</tt>" and "<tt>..</tt>" automatically. Any boolean context (in this case the <tt>not</tt> function) will do just enough work on the lazy list to determine whether there are any elements, so we don't have to count the directory entries, or even read them all into memory, if there are more than one buffer's worth.
=={{header|PHP}}==
Any improvements welcome but here is a starting point for PHP
Anonymous user