lua-users home
lua-l archive

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


Op Ma., 20 Aug. 2018 om 00:59 het Александр Машин
<alex.mashin@gmail.com> geskryf:

> as far as I understand the documentation on fold captures in LPEG

Try this primer:

https://github.com/dlaurie/lua-notes

Select "LPeg". You will find this explanation:

Cf(p,fct), p:Cf(fct) (Fold by Function) fct must be a function of two
variables. Think of it as a left-associative binary operator applied
between the captures of p. The result is the capture of Cf(p,fct).
(C(1)^3):match"361" returns '3','6','1' but
Cf(C(1)^3,math.max):match"361" returns 6.