Unix/ls: Difference between revisions

Content added Content deleted
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 74: Line 74:
end loop;
end loop;
end Directory_List;</lang>
end Directory_List;</lang>



=={{header|Aime}}==
=={{header|Aime}}==
Line 226: Line 225:
</lang>
</lang>


=={{header|C++}}==
{{libheader|Boost}}
<lang cpp>
#include <iostream>
#include <set>
#include <boost/filesystem.hpp>

namespace fs = boost::filesystem;

int main(void)
{
fs::path p(fs::current_path());
std::set<std::string> tree;

for (auto it = fs::directory_iterator(p); it != fs::directory_iterator(); ++it)
tree.insert(it->path().filename().native());

for (auto entry : tree)
std::cout << entry << '\n';
}
</lang>
=={{header|C sharp|C#}}==
=={{header|C sharp|C#}}==
<lang csharp>using System;
<lang csharp>using System;
Line 273: Line 251:
}
}
}</lang>
}</lang>

=={{header|C++}}==
{{libheader|Boost}}
<lang cpp>
#include <iostream>
#include <set>
#include <boost/filesystem.hpp>

namespace fs = boost::filesystem;

int main(void)
{
fs::path p(fs::current_path());
std::set<std::string> tree;

for (auto it = fs::directory_iterator(p); it != fs::directory_iterator(); ++it)
tree.insert(it->path().filename().native());

for (auto entry : tree)
std::cout << entry << '\n';
}
</lang>


=={{header|Clojure}}==
=={{header|Clojure}}==
Line 696: Line 696:
END.
END.
</lang>
</lang>

=={{header|Perl}}==
=={{header|Perl}}==


Line 708: Line 709:


<lang perl>print "$_\n" for glob '* .*'; # If you want to include dot files</lang>
<lang perl>print "$_\n" for glob '* .*'; # If you want to include dot files</lang>

=={{header|Perl 6}}==

There is a <tt>dir</tt> builtin command which returns a list of IO::Path objects. We stringify them all with a hyperoperator before sorting the strings.

<lang perl6>.say for sort ~«dir</lang>


=={{header|Phix}}==
=={{header|Phix}}==
Line 812: Line 807:


Both tests pass.
Both tests pass.

=={{header|Raku}}==
(formerly Perl 6)

There is a <tt>dir</tt> builtin command which returns a list of IO::Path objects. We stringify them all with a hyperoperator before sorting the strings.

<lang perl6>.say for sort ~«dir</lang>


=={{header|REXX}}==
=={{header|REXX}}==
Line 827: Line 829:
</lang>
</lang>
This will output all files including hidden ones e.g. '.' and '..'.
This will output all files including hidden ones e.g. '.' and '..'.

=={{header|Run BASIC}}==
=={{header|Run BASIC}}==
<lang Runbasic>files #f, DefaultDir$ + "\*.*" ' RunBasic Default directory.. Can be any directroy
<lang Runbasic>files #f, DefaultDir$ + "\*.*" ' RunBasic Default directory.. Can be any directroy
Line 900: Line 903:
b
b
</pre>
</pre>



=={{header|S-lang}}==
=={{header|S-lang}}==
Line 935: Line 937:
/usr
/usr
/var </pre>
/var </pre>

=={{header|Seed7}}==
=={{header|Seed7}}==
<lang seed7>$ include "seed7_05.s7i";
<lang seed7>$ include "seed7_05.s7i";