2014-01-05 20:05:08 +00:00
|
|
|
import Int.
|
2014-01-05 18:32:47 +00:00
|
|
|
(*
|
2013-12-20 03:08:10 +00:00
|
|
|
macro("MyMacro", { macro_arg.Expr, macro_arg.Comma, macro_arg.Expr },
|
2013-12-26 19:15:45 +00:00
|
|
|
function (env, e1, e2)
|
2013-12-20 03:08:10 +00:00
|
|
|
return Const({"Int", "add"})(e1, e2)
|
|
|
|
end)
|
|
|
|
macro("Sum", { macro_arg.Exprs },
|
2013-12-26 19:15:45 +00:00
|
|
|
function (env, es)
|
2013-12-20 03:08:10 +00:00
|
|
|
if #es == 0 then
|
|
|
|
return iVal(0)
|
|
|
|
end
|
|
|
|
local r = es[1]
|
|
|
|
local add = Const({"Int", "add"})
|
|
|
|
for i = 2, #es do
|
|
|
|
r = add(r, es[i])
|
|
|
|
end
|
|
|
|
return r
|
|
|
|
end)
|
2014-01-05 18:32:47 +00:00
|
|
|
*)
|
2013-12-20 03:08:10 +00:00
|
|
|
|
2014-01-05 19:03:35 +00:00
|
|
|
print (MyMacro 10, 20) + 20
|
|
|
|
print (Sum)
|
|
|
|
print Sum 10 20 30 40
|
|
|
|
print fun x, Sum x 10 x 20
|
2014-01-05 20:05:08 +00:00
|
|
|
eval (fun x, Sum x 10 x 20) 100
|