Module macro.forall

forall statement.

The syntax is forall VAR SELECT [if CONDN] do where SELECT is either in TBL or = START,FINISH

For example,

forall name in {'one','two'} do print(name) end

forall obj in get_objects() if obj:alive() then
    obj:action()
end

Using forall, we also define list comprehensions like L{s:upper() | s in names if s:match '%S+'}

Macros

forall extended for statement.
L list comprehension.


Macros

forall
extended for statement.
L
list comprehension. Syntax is L{expr | select} where select is as in forall, or L{expr for select} where select is as in the regular for statement.

Usage:

  • L{2*x | x in {1,2,3}} == {1,4,9}
  • L{2*x|x = 1,3} == {1,4,9}
  • L{{k,v} for k,v in pairs(t)}

see also: