home *** CD-ROM | disk | FTP | other *** search
- (* calc - the world's smallest string / integer expression evaluator
- n.b. independent of type read in *)
- (* supports integers, strings, lists of
- + - / * :: or and not head tail mid len
- *)
- (* Guy Verbist 1991 *)
-
-
- null function calc()
- {
- let string s := "";
- string s_to_eval;
- loop
- write("?-> ");
- read(s);
- exiton( (s="quit") or (s="end") or (s="exit") or (s = "q") or (s="x"));
- s_to_eval := "write(\"Answer is : \",eval({" + s + "}),\"\n\");";
- exec(compile(s_to_eval));
- endloop;
- };
-
- calc();
-