June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -1,6 +1,6 @@
void main() {
import std.stdio, std.file, std.path;
import std.stdio, std.file, std.path, std.array, std.algorithm;
foreach (const string path; dirEntries(getcwd, SpanMode.shallow))
foreach (const string path; dirEntries(getcwd, SpanMode.shallow).array.sort)
path.baseName.writeln;
}

View file

@ -0,0 +1,14 @@
1> Ls = fun(Dir) ->
1> {ok, DirContents} = file:list_dir(Dir),
1> [io:format("~s~n", [X]) || X <- lists:sort(DirContents)]
1> end.
#Fun<erl_eval.6.36634728>
2> Ls("foo").
bar
[ok]
3> Ls("foo/bar").
1
2
a
b
[ok,ok,ok,ok]

View file

@ -0,0 +1,18 @@
// Version 1.2.41
import java.io.File
fun ls(directory: String) {
val d = File(directory)
if (!d.isDirectory) {
println("$directory is not a directory")
return
}
d.listFiles().map { it.name }
.sortedBy { it.toLowerCase() } // case insensitive
.forEach { println(it) }
}
fun main(args: Array<String>) {
ls(".") // list files in current directory, say
}

View file

@ -0,0 +1 @@
OS.Process.system "ls -a"

View file

@ -0,0 +1,15 @@
local (* make a sort function *)
val rec insert = fn s :string =>fn [] => [s]
| ll as h::t => if s<=h then s::ll else h::insert s t;
in
val rec sort = fn [] => [] | h::t => insert h (sort t)
end;
open Posix.FileSys ;
val istream = opendir "." ;
val ll = ref [readdir istream] ;
while ( isSome (hd (!ll)) ) do ( ll:=readdir istream :: !ll );
val result = List.map valOf (tl (!ll));
closedir istream ;
sort result;