Files
orchid/examples/calculator/main.orc
Lawrence Bethlenfalvy 86e520e8b8 September-october commit
- manual parser
- stl refinements
- all language constructs are now Send
2023-10-11 18:27:50 +01:00

23 lines
575 B
Plaintext

import std::(to_float, to_string, panic, string::char_at)
export const main := do{
cps print "left operand: ";
cps data = readln;
let a = to_float data;
cps print "operator: ";
cps op = readln;
cps println ("you selected \"" ++ op ++ "\"");
cps print "right operand: ";
cps data = readln;
let b = to_float data;
let result = (
if op == "+" then a + b
else if op == "-" then a - b
else if op == "*" then a * b
else if op == "/" then a / b
else (panic "Unsupported operation")
);
cps println ("Result: " ++ to_string result);
0
}