On 25/10/2014 3:35 AM, Bob Rutledge wrote:
I would guess that, as previously suggested,
for i = 1, count do a[i] = a[i] * i end
would really rather be
for i = 1, count do a[i] = i * i end
Good eye Bob! When I copy and pasted the snippet into the e-mail it
dropped the square brackets. When I edited the code I inserted a bug!
Bloody square brackets will be the death of me!
Bob
Barkow, Eileen wrote:
I keep getting this error both in MVS and UNIX.
LUA: //'xcics.lua4z.samplib(cpu)':4: attempt to perform arithmetic on
field '? ' (a nil value) stack traceback:
//'xcics.lua4z.samplib(cpu)':4: in main
chunk ÝC¨: ? ***
-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]]
On Behalf Of Bass, Walter W
Sent: Friday, October 24, 2014 2:21 PM
To: [email protected]
Subject: Re: [ANN] Lua4z: the Lua programming language on z/OS, with
batteries
-----Original Message-----
From: IBM Mainframe Discussion List
[mailto:[email protected]] On Behalf Of David Crayford
Sent: Thursday, October 23, 2014 10:08 PM
To: [email protected]
Subject: Re: [ANN] Lua4z: the Lua programming language on z/OS, with
batteries>
<snip>
OK, let's try simple matrix multiplication which should test both
array access and math.
/* REXX */
arg count
if count = "" then count = 1000000
start = sysvar("SYSCPU")
do i = 1 to count
a.i = i * i
end
say 'CPU time = 'sysvar("SYSCPU") - start
CPU time = 3.57
local t = require("timer")()
local count = arg[1] or 1000000
local a = {}
for i = 1, count do a[i] = a[i] * i end
t:print_elapsed()
elapsed time: 0.131965
That's a huge difference, two orders of magnitude.
<snip remainder>
Maybe I'm just showing my ignorance of the Lua language syntax, but
this statement: " a[i] = a[i] * i "
Does not appear to be the equivalent to the REXX statement:
" a.i = i * i "
In fact, I would expect that the above Lua statement is actually
multiplying i by an uninitialized variable "a[i]". Assuming the
above code executes without error, then due to the principle of least
astonishment, I would imagine that this uninitialized value is
assumed to be zero.
If that IS what is happening, it will of course be MUCH faster to
compute i * 0 than to compute i squared.
Can someone with Lua syntax knowledge please enlighten me?
Thanks,
Bill Bass
United HealthCare / Optum
This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity
to which it is addressed. If the reader of this e-mail is not the
intended recipient or his or her authorized agent, the reader is
hereby notified that any dissemination, distribution or copying of
this e-mail is prohibited. If you have received this e-mail in error,
please notify the sender by replying to this message and delete this
e-mail immediately.
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions, send
email to [email protected] with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN