Field | Value |
---|---|
DIP: | (number/id -- assigned by DIP Manager) |
Author: | monkyyy, [email protected] |
Implementation: | (links to implementation PR if any) |
Status: | Draft |
This file contains hidden or 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; | |
alias seq=AliasSeq; | |
template isrange(alias R,string s){ | |
static if(__traits(compiles,mixin("isInputRange!(typeof(R."~s~"))"))){ | |
enum isrange=mixin("isInputRange!(typeof(R."~s~"))"); | |
} else { | |
enum isrange=false; | |
}} | |
template childranges(R){ | |
alias store=seq!(); |
This file contains hidden or 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 curryrecurse(alias F,int I=2,Args...)(Args args){ | |
static if(Args.length>I){ | |
static if(is(typeof(F(args[0..I]))==void)){ | |
F(args[0..I]); | |
curryrecurse!(F,I)(args[I..$]); | |
} else { | |
return curryrecurse!(F,I)(F(args[0..I]),args[I..$]); | |
}} else { | |
return F(args); | |
}} |
This file contains hidden or 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; | |
auto takeUntil(R)(R base,R other){ | |
static struct Result{ | |
R base; | |
R other; | |
alias base this; | |
bool empty()=>base==other; | |
} | |
return Result(base,other); | |
} |
This file contains hidden or 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
float lazyexo(byte i){ | |
if(i==-128){return 0;} | |
if(i<0){return 1/lazyexo(cast(byte)-i);} | |
enum table1=[0.0,1.0/5,1.0/3,1.0/2]; | |
enum table2=[1,2,5,10]; | |
float frac=table1[i%4]; | |
i/=4; | |
uint signif1=table2[i%4]; | |
i/=4; | |
signif1<<=i*4; |
This file contains hidden or 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
char[80] buffer="helloworld"; | |
void print(T)(ref T buf){ | |
asm{ | |
mov RAX, 1; | |
mov RDI, 1; | |
mov RSI,buf; | |
mov RDX,9; | |
syscall; | |
}} | |
void main(){ |
This file contains hidden or 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; | |
string expandmixin(string s){ | |
return "static if( __traits(compiles,"~s~")){ return "~s~";}"; | |
} | |
unittest{ | |
expandmixin("foo").writeln; | |
} | |
string elsejoin(string[] s){ | |
auto l=s.length; |
This file contains hidden or 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
--- bar.d | |
void min(int a,int b){} | |
void f1(){} | |
void f3(){} | |
void f5(int){} | |
--- foo.d | |
void min(float a,float b){} | |
void f2(){} |
This file contains hidden or 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
/* | |
a one char clock for 256 color teminals | |
red-yellow: am | |
teal-blue: pm | |
☀: noon | |
☾: midnight | |
red/teal: early hour | |
yellow/blue: late hour |
This file contains hidden or 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
/* minium viable std | |
every possible trade off to just get it done | |
orginaztion? nah mega file | |
more then 1 unittest? nah | |
docs? what for you have unittest | |
comprosmizes with other view points? nah everyone else wrong | |
effent code? nah, who needs it computers fast | |
good overloads? nah, just use it well | |
good error messages? nah just dont make typos | |
template meta programming to make things easier for the end user? no that would take 100x as long |