import console;
// 简单的高阶函数
forEach = function(t,f) for(k,v in t) f(v,k)
times = function(n, f) for(i=1;n) f(i)
unless = function(p,f) if(!p) f()
var t = {1,2,3,4,5};
forEach(t, lambda(v) unless(
v%2, λ() console.log(v, " is even")
))
times(10, lambda(n) unless(
n%2, λ() console.log(n, " is even")
))
console.log("--------------------------------")
// 函数调试
tap = function(v){
return lambda(f) unless (
!(type(f)==="function")
,λ() console.dumpJson (
["参数值"] = v,
["返回值"] = f(v) || "No return values!"
))
}
forEach(t, lambda(v) tap(v)( math.sqrt ))
console.pause(true);