Skip to content

Instantly share code, notes, and snippets.

@crazymonkyyy
Created March 31, 2023 20:07
Show Gist options
  • Save crazymonkyyy/57bf1128d6a01e2dfe2c754d5c57af49 to your computer and use it in GitHub Desktop.
Save crazymonkyyy/57bf1128d6a01e2dfe2c754d5c57af49 to your computer and use it in GitHub Desktop.
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;
if(s.canFind('=')){
t="success";
} else {
t=pipe.stdout.byLineCopy.front;
}
return t;
}
void main(){
init;
calc("a=10").writeln;
calc("a+a").writeln;
calc("1+3").writeln;
calc("1+4").writeln;
calc("1+5").writeln;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment