Backup commit before crunch
This commit is contained in:
20
examples/calculator/main.orc
Normal file
20
examples/calculator/main.orc
Normal file
@@ -0,0 +1,20 @@
|
||||
import std::(parse_float, to_string)
|
||||
import std::(readline, print)
|
||||
|
||||
export main := do{
|
||||
cps data = readline;
|
||||
let a = parse_float data;
|
||||
cps op = readline;
|
||||
cps print ("\"" ++ op ++ "\"\n");
|
||||
cps data = readline;
|
||||
let b = parse_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 "Unsupported operation" -- dynamically typed shenanigans
|
||||
);
|
||||
cps print (to_string result ++ "\n");
|
||||
0
|
||||
}
|
||||
Reference in New Issue
Block a user