lua-users home
lua-l archive

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


Cf is very specialized. Here is a toy example of how I understood it when I first learnt LPEG (string-to-number coercion was still OK then):
 
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.