2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1,21 +1,16 @@
import std.stdio, std.conv, std.datetime, std.array, core.thread;
import core.thread, std.concurrency, std.datetime,
std.stdio, std.algorithm, std.conv;
final class SleepSorter: Thread {
private immutable uint val;
void main(string[] args)
{
if (!args.length)
return;
this(in uint n) /*pure nothrow @safe*/ {
super(&run);
val = n;
}
foreach (number; args[1 .. $].map!(to!uint))
spawn((uint num) {
Thread.sleep(dur!"msecs"(10 * num));
writef("%d ", num);
}, number);
private void run() {
Thread.sleep(dur!"msecs"(1000 * val));
writef("%d ", val);
}
}
void main(in string[] args) {
if (!args.empty)
foreach (const arg; args[1 .. $])
new SleepSorter(arg.to!uint).start;
thread_joinAll();
}

View file

@ -0,0 +1,16 @@
defmodule Sort do
def sleep_sort(args) do
Enum.each(args, fn(arg) -> Process.send_after(self, arg, 5 * arg) end)
loop(length(args))
end
defp loop(0), do: :ok
defp loop(n) do
receive do
num -> IO.puts num
loop(n - 1)
end
end
end
Sort.sleep_sort [2, 4, 8, 12, 35, 2, 12, 1]