Skip to content

Instantly share code, notes, and snippets.

import basic;
void main(){
foreach(i;0..24){
"[ //".write;i.writeln;
" [Vector2(0,5)]".writeln;
"],".writeln;
if(i%5==4){
"".writeln;
}}}
//void main(){
import basic;
enum count=6;
enum nullchar='-';
enum correct='^';
enum misplaced='?';
alias format=char[count];
format hint(format geuss,format answer){
format o;
foreach(i;0..count){
o[i]=nullchar;
struct nullable(T){
T me; alias me this;
bool isnull=true;
this(T t){
me=t;
isnull=false;
}}
template match(A...){
auto match(T...)(T args){
static foreach(f;A[0..$-1]){ {
auto reindex(string indexstring,string lengthstring="l",R)(R range){
static struct reindex_{
R range;
int j=0;
auto opIndex(int i){
i+=j;
import basic;
mixin("return range["~indexstring~"];");
}
auto length(){

whitespace

principals

  1. tabs
  2. avoid meaningless whitespace, white space should communicate something fuzzy to humans
  3. {} are for the computer, not humans; inline it
  4. tabs are for a humans conception of scope
  5. whitespace should be used for human convience and to hightlight control flow
import std.datetime;
import core.thread;
import std.stdio;
auto now()=>Clock.currTime;
auto sleep(int i)=>Thread.sleep( dur!("seconds")(i));
alias time=typeof(now());
unittest{
auto a=now;
sleep(1);
time b=now;
@crazymonkyyy
crazymonkyyy / .d
Last active October 12, 2022 16:58
enum stuff
struct catigoryenum(T,I=ubyte){
T t; //alias t this;
I i;
auto opBinary(string s)(int j){
assert(j==1);
return typeof(this)(t,cast(I)(i+1));
}
bool opEquals(T s){
return s==t;
}
struct trifibtree{
int[4] nums;
trifibtree[3] children(){
trifibtree[3] o;
o[0]=trifibtree(nums[3],nums[1]);
o[1]=trifibtree(nums[3],nums[2]);
o[2]=trifibtree(nums[0],nums[2]);
return o;
}
this(int a,int b){
//aliasSeq shortened
alias Seq(TList...) = TList;
mixin template pullapartctinputs(){
alias ints=Seq!();
alias strings=Seq!();
alias bools=Seq!();
alias others=Seq!();
static foreach(T;ctinputs){
static if(is(typeof(T)==int)){
ints=Seq!(ints,T);
import std;
void main(string[] s){
("mkfifo "~s[1]).executeShell;
File data;
//data.open(s[1]);
while (true){
data.open(s[1]);
foreach(a;data.byLineCopy){
a.writeln;