About: API foreach   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

Apply the function f to the elements of the table passed. On each iteration the function f is passed the key-value pair of that element in the table. table.foreach(tab, func); foreach(tab, func); From TableLibraryTutorial of lua-users.org. > table.foreach({1,"two",3}, print) -- print the key-value pairs 1 1 2 two 3 3 > table.foreach({1,"two",3,"four"}, function(k,v) print(string.rep(v,k)) end) 1 twotwo 333 fourfourfourfour If the function f returns a non-nil value the iteration loop terminates.

AttributesValues
rdfs:label
  • API foreach
rdfs:comment
  • Apply the function f to the elements of the table passed. On each iteration the function f is passed the key-value pair of that element in the table. table.foreach(tab, func); foreach(tab, func); From TableLibraryTutorial of lua-users.org. > table.foreach({1,"two",3}, print) -- print the key-value pairs 1 1 2 two 3 3 > table.foreach({1,"two",3,"four"}, function(k,v) print(string.rep(v,k)) end) 1 twotwo 333 fourfourfourfour If the function f returns a non-nil value the iteration loop terminates.
dbkwik:wowwiki/pro...iPageUsesTemplate
abstract
  • Apply the function f to the elements of the table passed. On each iteration the function f is passed the key-value pair of that element in the table. table.foreach(tab, func); foreach(tab, func); From TableLibraryTutorial of lua-users.org. > table.foreach({1,"two",3}, print) -- print the key-value pairs 1 1 2 two 3 3 > table.foreach({1,"two",3,"four"}, function(k,v) print(string.rep(v,k)) end) 1 twotwo 333 fourfourfourfour If the function f returns a non-nil value the iteration loop terminates. > table.foreach({1,"two",3}, function(k,v) print(k,v) return k<2 and nil end) 1 1 2 two Tables can contain mixed key-value and index-value elements. table.foreach() will display all of the elements in a table. To only display the index-value elements see table.foreachi(). For more information about this subject see the TablesTutorial. > t = { 1,2,"three"; pi=3.14159, banana="yellow" } > table.foreach(t, print) 1 1 2 2 3 three pi 3.14159 banana yellow
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software