Arithmetic with multiple lua return values

Is it possible to perform arithmetic on multiple values ​​in Lua. I am using Lua for Windows 5.1.4.

Currently, I have to put several values ​​in a table and then unzip them, and I would like to skip this step.

Is it possible.

Here is what I have now:

function numsToStr(...) local nums = {} for i,v in ipairs({...}) do nums[i] = v + string.byte('A') - 1 end return string.char(unpack(nums)) end 

I want it to be possible

 function numsToStr(...) return string.char(...+string.byte('A')-1) end 
+4
source share
2 answers

No, it is not possible to perform arithmetic on multiple values ​​in Lua.

+4
source

It is impossible to execute "directly", but you can implement the "map" function, similar to what you did. Some relevant resources: short anonymous functions , a stream on a Perl-like map / grep functions, and a map and other functions . Also view the list in Penlight .

+4
source

Source: https://habr.com/ru/post/1494828/


All Articles