// Dec will decrement a variable. // args[0] - variable name // args[1] - quantum of value to decrement // if variable name is present in local scope it will be used, // otherwise variable name from global scope is used. func Dec(scope common.Scope, args ...interface{}) interface{} { name, by := args[0].(string), int64(1) if len(args) > 1 { by = args[1].(int64) } vali, g, ok := scope.Get(name) if ok { scope.Set(name, vali.(int64)-by, g) } return "" }
// Let will define a set of one or more variables in // local scope. // args[0], args[2] ... args[N-1] - variable name // args[1], args[3] ... args[N] - variable value func Let(scope common.Scope, args ...interface{}) interface{} { for i := 0; i < len(args); i += 2 { scope.Set(args[i].(string), args[i+1], false /*global*/) } return "" }