[med-svn] [cnrun] 07/14: choose appropriate unpack function in example.lua wrt lua version
andrei zavada
hmmr-guest at moszumanska.debian.org
Sat Feb 21 15:07:35 UTC 2015
This is an automated email from the git hooks/post-receive script.
hmmr-guest pushed a commit to branch WIP
in repository cnrun.
commit 5d92faab58a1895dadad061acd614ea17939a031
Author: andrei zavada <johnhommer at gmail.com>
Date: Mon Dec 8 01:39:43 2014 +0200
choose appropriate unpack function in example.lua wrt lua version
---
upstream/doc/examples/example1.lua | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/upstream/doc/examples/example1.lua b/upstream/doc/examples/example1.lua
index 2feca9f..3f91c82 100644
--- a/upstream/doc/examples/example1.lua
+++ b/upstream/doc/examples/example1.lua
@@ -16,7 +16,10 @@
-- 4. Don't lose the context object. It will not be gabage-collected
-- for you (it is a C++ thing).
--- To execute this script with lua-5.1, do s/table.unpack/unpack/g.
+local effective_unpack = table.unpack
+if _VERSION == "Lua 5.1" then
+ effective_unpack = unpack
+end
local M = require("cnrun")
@@ -45,7 +48,7 @@ print ("Setting verbosely to 4")
M.set_model_parameter (C, mname, "verbosely", 4)
result = {M.list_models (C)}
-res, ult = result[1], {table.unpack(result, 2)}
+res, ult = result[1], {effective_unpack(result, 2)}
if res == nil then
print (ult)
return
@@ -88,7 +91,7 @@ end
result = {M.get_units_matching(C, mname, "L.*")}
-res, ult = result[1], {table.unpack(result, 2)}
+res, ult = result[1], {effective_unpack(result, 2)}
if res == nil then
print (ult)
return
@@ -103,7 +106,7 @@ print (string.format(
print (string.rep('-', 87))
for _, u in ipairs(unit_list) do
result = {M.get_unit_properties (C, mname, u)}
- res, ult = result[1], {table.unpack(result, 2)}
+ res, ult = result[1], {effective_unpack(result, 2)}
local b = function (x) if x then return "yes" else return "no" end end
print (string.format(
fmt,
@@ -155,7 +158,7 @@ print ("State variables:")
for i = 1, 6, 1 do
M.advance (C, mname, 1000)
result = {M.get_unit_vars (C, mname, "LNz.0")}
- res, ult = result[1], {table.unpack(result, 2)}
+ res, ult = result[1], {effective_unpack(result, 2)}
print (table.concat(ult, '; '))
end
print()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/cnrun.git
More information about the debian-med-commit
mailing list