begin public compile, eval, lambda use cas.syntax: SyntaxError use cas.base use math _eval_ = eval SymbolicExpression = table(Type,"SymbolicExpression") { function string syntax.ast_to_string(self.value) end } function symbolic(s) return table SymbolicExpression{value = syntax.compile(s)} end function eval(s,m=null) return table SymbolicExpression{ value = base.eval(syntax.compile(s),m) } end env_math = { pi = math.pi, e = math.e, sin = math.sin, cos = math.cos, tan = math.tan } function lambda(id,t) return _eval_("|{}| {}"%[id,str(t)],env_math) end end