Skip to content

Instantly share code, notes, and snippets.

View run-dlang's full-sized avatar

Eleanor Cross run-dlang

View GitHub Profile
@run-dlang
run-dlang / main.d
Created October 12, 2023 07:50
Code shared from run.dlang.io. Run with '-unittest'
import std.stdio : writeln, toFile;
import std.datetime.stopwatch : StopWatch, AutoStart;
import asdf.serialization : deserialize, serializeToJson;
import std.file : readText;
import std.array: array;
import std.algorithm : copy, map;
enum TopN = 5;
struct Post
@run-dlang
run-dlang / main.d
Created October 12, 2023 06:27
Code shared from run.dlang.io.
import std;
void main()
{
writeln("Hello D");
}
@run-dlang
run-dlang / main.d
Created October 9, 2023 15:04
Code shared from run.dlang.io. Run with '-preview=bitfields'
import std;
alias bit = bool;
struct integer
{
bit
sign: 1,
bit1: 1,
bit2: 1,
bit3: 1,
@run-dlang
run-dlang / main.d
Created October 9, 2023 15:03
Code shared from run.dlang.io. Run with '-preview=bitfields'
import std;
struct integer
{
bool
sign: 1,
bit1: 1,
bit2: 1,
bit3: 1,
bit4: 1,
bit5: 1,
@run-dlang
run-dlang / main.d
Created October 8, 2023 19:59
Code shared from run.dlang.io.
import std;
struct Iter(T){
T[] data;
// Sometimes folks wrap the iterator in an 'anonymous struct'
// In a way this 'separates' it from the actual data structure.
// I like that it also hides the fact that when you do copies
// and such, that you don't need to copy 'currentPos'.
// Maybe it depends on the
@run-dlang
run-dlang / main.d
Created October 6, 2023 16:12
Code shared from run.dlang.io.
import std.stdio;
void main() {
int a ;
short h ;
ushort o ; // on utilise les type non signés lorsque nous nous attendons à ce que nos données ne puissent par exemple ne jamais être inférieures à zero. Donc si vous representez l'âge de quelqu'un sous forme de structure de données par exemple, vous devriez utiliser un non signier type
char b = 'B';
wchar x ; // caractère large si on veut ecrire d'autres caractres
long y ;
@run-dlang
run-dlang / main.d
Created October 6, 2023 16:12
Code shared from run.dlang.io.
import std.stdio;
void main() {
int a ;
short h ;
ushort o ; // on utilise les type non signés lorsque nous nous attendons à ce que nos données ne puissent par exemple ne jamais être inférieures à zero. Donc si vous representez l'âge de quelqu'un sous forme de structure de données par exemple, vous devriez utiliser un non signier type
char b = 'B';
wchar x ; // caractère large si on veut ecrire d'autres caractres
long y ;
@run-dlang
run-dlang / main.d
Created October 6, 2023 08:36
Code shared from run.dlang.io.
import std;
void main()
{
    real x = 3.14159265358979323846364e300;
    real y = -3.14159265358979323846364e3000L;
    float z = -3.14159265358979323846364e30L;
    float t = z^^2;
   
       
 
@run-dlang
run-dlang / main.d
Created October 6, 2023 07:49
Code shared from run.dlang.io.
import std;
void main()
{
    real x = 3.14159265358979323846364e300;
    double y = -3.14159265358979323846364e3000L;
    float z = -3.14159265358979323846364e30;
       
 
   writefln ("x = %.1g",x);
   writefln ("y = %.2g",y);
@run-dlang
run-dlang / main.d
Created October 5, 2023 21:02
Code shared from run.dlang.io.
/+dub.sdl:
dependency "lubeck" version="~>1.5.4"
+/
import std;
void main()
{
writeln("Hello D");
}