Skip to content

Instantly share code, notes, and snippets.

Avatar

Eleanor Cross run-dlang

View GitHub Profile
@run-dlang
run-dlang / main.d
Created Jan 20, 2022
Code shared from run.dlang.io.
View main.d
import std;
int* f()
{
int a;
return &a;
}
void main()
{
@run-dlang
run-dlang / main.d
Created Jan 16, 2022
Code shared from run.dlang.io.
View main.d
import core.math;
import std;
void main()
{
const lval = rndtonl(5.0L);
writeln("lval = %d", lval);
}
@run-dlang
run-dlang / main.d
Created Jan 15, 2022
Code shared from run.dlang.io.
View main.d
import std.stdio;
enum EventType
{
WindowResize,
WindowTitleChange
}
struct WindowResize
{
@run-dlang
run-dlang / main.d
Created Jan 12, 2022
Code shared from run.dlang.io. Run with '-dip1000'
View main.d
import core.lifetime : forward, move, emplace;
import std.experimental.allocator.mallocator;
import std.traits : isIntegral, isMutable;
import std.stdio : writeln;
void main(){
scope SharedPtr!long top = SharedPtr!long.make(-1);
writeln("shared ptr:");
@run-dlang
run-dlang / main.d
Created Jan 12, 2022
Code shared from run.dlang.io. Run with '-dip1000'
View main.d
import core.lifetime : forward, move, emplace;
import std.experimental.allocator.mallocator;
import std.traits : isIntegral, isMutable;
import std.stdio : writeln;
void main()@safe{
scope SharedPtr!long top = SharedPtr!long.make(-1);
writeln("shared ptr:");
@run-dlang
run-dlang / main.d
Created Jan 12, 2022
Code shared from run.dlang.io. Run with '-dip1000'
View main.d
import core.lifetime : forward, move, emplace;
import std.experimental.allocator.mallocator;
import std.traits : isIntegral, isMutable;
import std.stdio : writeln;
void main()@safe{
scope SharedPtr!long top = SharedPtr!long.make(-1);
writeln("shared ptr:");
@run-dlang
run-dlang / main.d
Created Jan 12, 2022
Code shared from run.dlang.io. Run with '-dip1000'
View main.d
import core.lifetime : forward, move, emplace;
import std.experimental.allocator.mallocator;
import std.traits : isIntegral, isMutable;
import std.stdio : writeln;
void main()@safe{
scope SharedPtr!long top = SharedPtr!long.make(-1);
writeln("shared ptr:");
@run-dlang
run-dlang / main.d
Created Jan 12, 2022
Code shared from run.dlang.io. Run with '-dip1000'
View main.d
import core.lifetime : forward, move, emplace;
import std.experimental.allocator.mallocator;
import std.traits : isIntegral, isMutable;
import std.stdio : writeln;
void main()@safe{
scope SharedPtr!long top = SharedPtr!long.make(-1);
writeln("shared ptr:");
@run-dlang
run-dlang / main.d
Created Jan 10, 2022
Code shared from run.dlang.io. Run with '-unittest'
View main.d
void main()
{
import std.datetime.stopwatch : benchmark;
import std.math, std.parallelism, std.stdio;
auto logs = new double[100_000];
auto bm = benchmark!({
foreach (i, ref elem; logs)
elem = log(1.0 + i);
}, {
@run-dlang
run-dlang / main.d
Created Jan 10, 2022
Code shared from run.dlang.io. Run with '-unit test'
View main.d
/+dub.sdl:
dependency "sumtype" version="~>1.2.0"
dependency "emsi_containers" version="~>0.9.0"
+/
void main()
{
import std.range, std.stdio;
auto sum = 0.0;
auto count = stdin //Get an input range set up to read one line at a time