Try online at: https://run.dlang.io/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Zero = []; | |
type NN = number[]; | |
type GetNN<N extends NN> = N['length']; | |
type NextNN<N extends NN> = [...N, N['length']]; | |
type PrevNN<N extends NN> = N extends [...infer Init, infer _] ? Init : never; | |
type EqualNN<A extends NN, B extends NN> = | |
GetNN<A> extends GetNN<B> ? true : false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import core.thread : thread_joinAll, Thread, ThreadGroup, Fiber; | |
import std.stdio : writefln; | |
void main() | |
{ | |
writefln("Running on the main thread with id: '%s'", Thread.getThis().id); | |
auto fiber = new Fiber(() { | |
writefln("[before suspend] Running inside fiber on thread id '%s'", Thread.getThis().id); | |
Fiber.yield(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while IFS="" read -r line; do | |
project_path=$(echo "$line" | sed -E 's"(git@|.+://)[^:/]+[:/](.+)/.+$"\2"') | |
repo_name=$(echo "$line" | sed -E -e 's|.+/(.+)$|\1|' -e 's|(.+)(.git)$|\1|') | |
echo "* '$line'" | |
echo " * '$project_path'" | |
echo " * '$repo_name'" | |
echo | |
done < ./example_urls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface ICallable | |
{ | |
void opCall() const; | |
} | |
auto makeDelegate(alias fun, Args...)(auto ref Args args) | |
{ | |
return new class(args) ICallable | |
{ | |
Args m_args; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void genericToString(T, Writer)(scope ref const T obj, scope ref Writer writer) | |
{ | |
import std.format : formattedWrite; | |
writer.formattedWrite("Transaction {\n"); | |
writer.formattedWrite!" from: 0x%s\n"(obj.from.chars); | |
writer.formattedWrite!" to: 0x%s\n"(obj.to.chars); | |
writer.formattedWrite("}"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.json : JSONValue, parseJSON; | |
T fromJson(T)(JSONValue j) | |
{ | |
import std.traits : isNumeric; | |
// Handle JSON number and boolean values: | |
static if (is(typeof(j.get!T))) | |
return j.get!T; |
NewerOlder