Skip to content

Instantly share code, notes, and snippets.

struct optassoarray(V, K) {
struct triple {
ulong index;
K key;
V value;
auto tuple(){
import std.typecons:t=tuple;
return t(index,key,value);
}
}
import std;
ProcessPipes pipe;
void init(){
pipe=pipeShell("calc -p");
pipe.stdout.byLine.take(10);
}
string calc(string s){
pipe.stdin.writeln(s);
pipe.stdin.flush;
string t;
bool isascii(dchar c){
return c <dchar(127);
}
auto processtext(dstring s){
import std.sumtype;
struct range{
dstring s;
bool isunicode;
long i,j;
alias sumtype=SumType!(string,dchar);
bool isascii(dchar c){
return c <dchar(127);
}
auto processtext(dstring s){
import std.sumtype;
struct range{
dstring s;
bool isunicode;
long i,j;
alias sumtype=SumType!(string,dchar);
void replacebestmatch(alias distencefun,T)(ref T value,T[] pattern){
size_t i;
typeof(distencefun(T.init,T.init)) best;
best=typeof(best).max;
foreach(j,e;pattern){
auto temp=distencefun(value,e);
if(temp<best){
best=temp;
i=j;
}
import std;
struct verifiedindex{
int i;
}
auto enumeratedfilter(alias F,R)(R r){
struct range{
R r;
R r_old;
auto front(){return tuple(verifiedindex(i),r.front);}
int i;
import std;
enum filename="base-16.csv";
struct color{
int r;
int g;
int b;
}
auto rebase(T)(T a, T min, T max){
if(a>=min&&a<=max){
return a-min;
/*
dsl for piping generating 'pipexec' commands
```
foo | bar |
cat
---
c:42>f:69
```
will have foo piping into bar into foo
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;
//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);