lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

2015-07-17 11:56 GMT+02:00 Pierre Chapuis <>:
>> On Thu, Jul 16, 2015 at 4:00 PM, Tim Caswell <> wrote:
>>> This is one of those areas where languages without infix notation, but
>>> variable-length arguments (like lisp) smile.  You can just do (< x y z)
>>> and
>>> it will do what you expect or (< (<x y) z) to simulate the lua
>>> behaviour.
>>> But then you have to give up infix notation and/or have crazy
>>> conventions
>>> like {x < y < z} means to transform to (< x y z) if curly braces are
>>> used
>>> and every odd symbol is the same.
>> It's also possible to do it at the grammar level, defining the
>> comparison operators as being optionally ternary.
> If you allow that, you probably also want to allow x < y <= z and the like.

APL has an operator "scan" over arrays so that

   fct / x

returns the value of a function that can be coded in Lua as

function scan(fct,x)
   result = unit(fct)
   for _,v in ipairs(x) do result = fct(result,v) end
   return result

There may well be som such function in Penlight and Microlight.