lua-users home
lua-l archive

Separator in table concatenation

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


It would be nice if table.concat behaved like string.gsub:
 table.concat(tbl,sep)
would allow `sep` to be not only a string, but also a table or
function, indexed or called with the current list index.
E.g.
 tbl = {"A","B","C"}
 enumerate = function(k)
 return ", "..tostring(k+1)..": "
 end
 print("1: "..table.concat(tbl,enumerate))
1: A, 2: B, 3: C

AltStyle によって変換されたページ (->オリジナル) /