- tabs
- avoid meaningless whitespace, white space should communicate something fuzzy to humans
- {} are for the computer, not humans; inline it
- tabs are for a humans conception of scope
- whitespace should be used for human convience and to hightlight control flow
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 basic; | |
void main(){ | |
foreach(i;0..24){ | |
"[ //".write;i.writeln; | |
" [Vector2(0,5)]".writeln; | |
"],".writeln; | |
if(i%5==4){ | |
"".writeln; | |
}}} | |
//void main(){ |
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 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; |
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
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]){ { |
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
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(){ |
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.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; |
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
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; | |
} |
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
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){ |
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
//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); |
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; | |
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; |
OlderNewer