About: API foreachi   Sponge Permalink

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

From TableLibraryTutorial of lua-users.org. table.foreachi(table, f) foreaci(table, f) Apply the function f to the elements of the table passed. On each iteration the function f is passed the index-value pair of that element in the table. This is similar to table.foreach() except that index-value pairs are passed, not key-value pairs. If the function f returns a non-nil value the iteration loop terminates. > t = { 1,2,"three"; pi=3.14159, banana="yellow" } > table.foreachi(t, print) 1 1 2 2 3 three

AttributesValues
rdfs:label
  • API foreachi
rdfs:comment
  • From TableLibraryTutorial of lua-users.org. table.foreachi(table, f) foreaci(table, f) Apply the function f to the elements of the table passed. On each iteration the function f is passed the index-value pair of that element in the table. This is similar to table.foreach() except that index-value pairs are passed, not key-value pairs. If the function f returns a non-nil value the iteration loop terminates. > t = { 1,2,"three"; pi=3.14159, banana="yellow" } > table.foreachi(t, print) 1 1 2 2 3 three
dbkwik:wowwiki/pro...iPageUsesTemplate
abstract
  • From TableLibraryTutorial of lua-users.org. table.foreachi(table, f) foreaci(table, f) Apply the function f to the elements of the table passed. On each iteration the function f is passed the index-value pair of that element in the table. This is similar to table.foreach() except that index-value pairs are passed, not key-value pairs. If the function f returns a non-nil value the iteration loop terminates. > t = { 1,2,"three"; pi=3.14159, banana="yellow" } > table.foreachi(t, print) 1 1 2 2 3 three Note in the example only the indexed elements of the table are displayed. See the TablesTutorial for more information on key-value and index-value pairs. Also note that foreachi starts at index [1], increments the index by one repeatedly, and stops running as soon as it reaches a nil value. This is an example: > t = { [0] = "zero", --will not be counted [1] = "one", --will be counted; 1 [2] = "two", --will be counted; 2 [3] = "three", --will be counted; 3 ["four"] = "four", --will not be counted; returns 3 [5] = "five" } --will never be reached > foreachi(t, print) 1 one 2 two 3 three In the above, it starts at t[1] (not t[0]) and counts to t[3], printing the corresponding values along the way. It then checks t[4], sees it is nil, and stops running. t[5] is never checked - this will not hit every array index in a table, only the consecutive ones from one up until it hits its first blank index.
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