gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/lm-helpers.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lm-helpers.lua')
-rw-r--r--lm-helpers.lua 37
1 files changed, 37 insertions, 0 deletions
diff --git a/lm-helpers.lua b/lm-helpers.lua
new file mode 100644
index 00000000..48a5685e
--- /dev/null
+++ b/lm-helpers.lua
@@ -0,0 +1,37 @@
+local LM = {}
+
+local factor_mt
+
+local function mul_factor(a, b)
+ local c = {value= a.value .. ":" .. b.value}
+ return setmetatable(c, factor_mt)
+end
+
+factor_mt = {
+ __mul = mul_factor,
+}
+
+function LM.factor(name)
+ local t = {name= name, value = ""}
+ return setmetatable(t, factor_mt)
+end
+
+function LM.eval_test(...)
+ local inf = {np = select('#', ...)}
+ inf.class = {}
+ for k= 1, inf.np do
+ local v = select(k, ...)
+ inf.class[k] = (type(v) == 'number' and 1 or 0)
+ end
+ return inf
+end
+
+function LM.eval_func(inf, pt, i, ...)
+ for k = 1, inf.np do
+ local x = select(k, ...)
+ local value = (inf.class[k] == 1 and x or x.value)
+ gdt.set(pt, i, k, value)
+ end
+end
+
+return LM
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月21日 11:15:21 +0000

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