Created
March 31, 2023 20:07
-
-
Save crazymonkyyy/57bf1128d6a01e2dfe2c754d5c57af49 to your computer and use it in GitHub Desktop.
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; | |
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