gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/expr-print.lua
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2013年05月12日 23:17:57 +0200
committerFrancesco Abbate <francesco.bbt@gmail.com>2013年05月12日 23:17:57 +0200
commit338fd9e668b582105def249a3be6a377d0160272 (patch)
tree65f2c2324b85ecb7722b9a517d04764a3774632f /expr-print.lua
parent204fa404431f9c619f0dfc5ae3efc463749fa8ed (diff)
downloadgsl-shell-338fd9e668b582105def249a3be6a377d0160272.tar.gz
WIP: fix problems with gdt.lm implementation
Use variadic functions for stateless expr evaluation. Do not store levels for numeric variables. Separate computation of levels and names from model matrix computations.
Diffstat (limited to 'expr-print.lua')
-rw-r--r--expr-print.lua 12
1 files changed, 6 insertions, 6 deletions
diff --git a/expr-print.lua b/expr-print.lua
index 03b1e185..ebbc6518 100644
--- a/expr-print.lua
+++ b/expr-print.lua
@@ -67,13 +67,13 @@ local function eval_operator(op, a, b)
else error('unkown operation: ' .. op) end
end
-local function eval(expr, scope, scope_state)
+local function eval(expr, scope, ...)
if type(expr) == 'number' then
return expr
elseif type(expr) == 'string' then
- return scope.ident(expr, scope_state)
+ return scope.ident(expr, ...)
elseif expr.func then
- local arg_value = eval(expr.arg, scope, scope_state)
+ local arg_value = eval(expr.arg, scope, ...)
if arg_value then
local f = scope.func(expr)
if not f then error('unknown function: ' .. expr.func) end
@@ -81,11 +81,11 @@ local function eval(expr, scope, scope_state)
end
else
if #expr == 1 then
- local v = eval(expr[1], scope, scope_state)
+ local v = eval(expr[1], scope, ...)
if v then return -v end
else
- local a = eval(expr[1], scope, scope_state)
- local b = eval(expr[2], scope, scope_state)
+ local a = eval(expr[1], scope, ...)
+ local b = eval(expr[2], scope, ...)
if a and b then
return eval_operator(expr.operator, a, b)
end
generated by cgit v1.2.3 (git 2.25.1) at 2025年10月02日 05:55:33 +0000

AltStyle によって変換されたページ (->オリジナル) /