function square(state,control)if(control>=state) thenreturn nilelsecontrol=control+1return control,control*controlendend
for k,v in square,9,0 doprint(k,v)end
泛型for本来就是这么写的啊。pairs()那么写是因为它能返回需要的3个值。