[NTG-context] final thoughts on experiments with lua

Henning Hraban Ramm texml at fiee.net
Thu Jan 10 12:11:08 CET 2019


Am 2019-01-10 um 10:50 schrieb luigi scarso <luigi.scarso at gmail.com>:

>> sections = { “1”, “2”, “2a” }
>> 
>> words = { [“1”] = { “a”, “b” },
>>           [“2a”] = { “c”, “d” } }
>> 
>> so I can iterate through ipairs(sections) in sequence and pick up the word lists for each section. In the greater scheme of things, as Hraban pointed out: if there were an “ordered table” structure in Lua, this is precisely what it would do behind the scenes; it would just make it easier for the user.
>> 
> the point is that I believe that is also doable in lua...
> maybe could be helpful to have a significative example in python, ton see if we can mimic it in lua  ?

The "minimal example" in Python is a collections.OrderedDict. It’s not about ordering the entries (anew), but keeping the order, i.e. retrieving the entries in the same order as you added them. If you iterate over a Python dict or a Lua pairs table, the order can be arbitrary.

Greetlings, Hraban
---
https://www.fiee.net
http://wiki.contextgarden.net
https://www.dreiviertelhaus.de
GPG Key ID 1C9B22FD



More information about the ntg-context mailing list