From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/95610 Path: news.gmane.org!.POSTED!not-for-mail From: Joseph Canedo Newsgroups: gmane.comp.tex.context Subject: Re: lua tables - how do you cope? Date: Sat, 30 Jul 2016 15:04:05 +0200 Message-ID: <579ca5be.031dc20a.f2c35.463e@mx.google.com> References: <8733E1CA-0DFE-4B10-BC34-9CEC8BB246AB@uni-bonn.de> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7929118585830737099==" X-Trace: blaine.gmane.org 1469887324 12995 80.91.229.8 (30 Jul 2016 14:02:04 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 30 Jul 2016 14:02:04 +0000 (UTC) To: Schmitz Thomas A. , mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sat Jul 30 16:01:47 2016 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bTUo9-0002Xv-Uo for gctc-ntg-context-518@m.gmane.org; Sat, 30 Jul 2016 16:00:06 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 1719B139F9; Sat, 30 Jul 2016 15:04:13 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id C6NhrVLkaQIr; Sat, 30 Jul 2016 15:04:11 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [IPv6:::1]) by zapf.ntg.nl (Postfix) with ESMTP id 9F6C213963; Sat, 30 Jul 2016 15:04:11 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 9C89613959 for ; Sat, 30 Jul 2016 15:04:10 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PBDCicyf4Knv for ; Sat, 30 Jul 2016 15:04:09 +0200 (CEST) Original-Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 6BFB413953 for ; Sat, 30 Jul 2016 15:03:59 +0200 (CEST) Original-Received: by mail-wm0-f49.google.com with SMTP id f65so319053825wmi.0 for ; Sat, 30 Jul 2016 06:03:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:mime-version:to:from:subject:date:importance:in-reply-to :references; bh=9NXJDWP2+fsq9yx4gLXCPTccI3FfG4xvf0nE7+DEDNQ=; b=jvyK7DDcz50UfwlAzhXdcu66ThiU+oRuP5gF/+sGbfCfzC3pHhK1HieU8G9Kt/Bp0R wVkJSas6GSC3wr0KLChGGkCvOVbz0x+0QLxBYCHoFRfYY25pNA3bzwOoGrS2MiAXb88M zkjMn06jNR9lB/RpSzqYaD6FSzKtrOmmUUWgN369g4ubMNdfxaeEG4DtszmDcjZj0/Fw 83Yq0PzkrkTweHBwrwiNToPFkuAk8FZHF8dimgJgbUS5hUc2maZwBtW88bZ1JQ7bvSsl Dx/8V2s/LmheQuTc4lA05DFDTUMIUgzDVa0osHqluRieQLZmLG8ujgV7h5VpuJl96ISS wB6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:mime-version:to:from:subject:date :importance:in-reply-to:references; bh=9NXJDWP2+fsq9yx4gLXCPTccI3FfG4xvf0nE7+DEDNQ=; b=OvRu+5R3EiurhpP4AI3nME5/6h8opmuVjYEfaRq0bFi49S0lN9djyLVwTxR6kJnF1e 2Ap0lQPd5BNBij2ggqDCADmuI00H1WsGc+AqU3obZuCzLPUqhJsd41A47hsRZHicE/G2 IqTS/gnRtTxl/tc+gHaXr/ZLFJi+N0ZwCpCIlsShA5bs4b5knqFJi5plGBUc3t0q6pMe ZuDZOLWF0g8zkXOOdGxzldLj6Tuddl2r+pmHXuMJ+/EKRhzrr/tHCIFNun+LUNc8lH+q UYCwDtC0Yj7psFcYOwcJDkmzdLTX9mTXoN1O52vYg3epmq5rgSMjq83aQ7gPA+4qoRzt Wkvw== X-Gm-Message-State: AEkoous2JD/tOT1LCTYvp5slJpqQ6BarbpT5v+QW8NikATQHmJT5TVNfH6+MCb5/fyDALw== X-Received: by 10.194.77.142 with SMTP id s14mr42056288wjw.77.1469883838880; Sat, 30 Jul 2016 06:03:58 -0700 (PDT) Original-Received: from ?IPv6:2a01:cb00:822:c400:7ce8:fb84:9e8e:89ba? (2a01cb000822c4007ce8fb849e8e89ba.ipv6.abo.wanadoo.fr. [2a01:cb00:822:c400:7ce8:fb84:9e8e:89ba]) by smtp.gmail.com with ESMTPSA id f3sm21260312wjh.2.2016.07.30.06.03.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Jul 2016 06:03:58 -0700 (PDT) Importance: normal X-Priority: 3 In-Reply-To: <8733E1CA-0DFE-4B10-BC34-9CEC8BB246AB@uni-bonn.de> X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.16 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.org gmane.comp.tex.context:95610 Archived-At: --===============7929118585830737099== Content-Type: multipart/alternative; boundary="_6E2C4B41-1080-4EA4-82D2-E853CD41F2E3_" --_6E2C4B41-1080-4EA4-82D2-E853CD41F2E3_ Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If the requirement is to iterate on a table having the keys, values sorted = by key (assuming the keys can be sorted), there are ways to do this. Please= see http://lua-users.org/wiki/SortedIteration for an example (this just re= places pairs(t) with orderedPairs(t)). Hope this helps Joseph De=C2=A0: Schmitz Thomas A.= --_6E2C4B41-1080-4EA4-82D2-E853CD41F2E3_ Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="utf-8"

If the requirement is to iterate on a = table having the keys, values sorted by key (assuming the keys can be sorte= d), there are ways to do this. Please see http://lua-users.org/wiki/SortedIteration for an e= xample (this just replaces pairs(t) with orderedPairs(t)).

 

Hope this helps

 

Joseph

 

De : Schmitz Thomas A.
Envoy= =C3=A9 le :samedi 30 juillet 2016 12:21
=C3=80 : mailing list for ConTeXt users
<= b>Objet :[NTG-context] lua tables - how do you cope?

 

This is less a = specific question about ConTeXt than a hope for good advice: I=E2=80=99m ma= ltreating my xml files with a mixture of TeX and Lua. I want to extract and= typeset information in different forms, so I first collect everything in l= ua tables, rearrange and order these tables and typeset the results. All fi= ne and dandy. My problem is that I have to have tables within tables within= tables=E2=80=A6 you get the picture. One aspect of Lua that is really bugg= ing me is the fact that associative tables have no order, which can be a pa= in in the butt for this kind of operation. So I have to be careful that I h= ave to use constructs that will keep the order in which items have been add= ed and loop through them via ipairs() instead of pairs(). I find it difficu= lt to keep track of what=E2=80=99s inside my layers upon layers of tables. = So my question is: how do those of you who are more experienced with this k= ind of question proceed? Do you have any handy tool to visualize a table? A= ny tips you want to share?

 

Thanks a lot!

 

Thomas

_____________________= ______________________________________________________________

If your question is of interest to others as well, please add = an entry to the Wiki!

 

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/list= info/ntg-context

webpage =C2=A0: http://www.pragma-= ade.nl / http://tex.aanhet.net

archive=C2=A0 : http= ://foundry.supelec.fr/projects/contextrev/

wiki=C2= =A0=C2=A0=C2=A0=C2=A0 : http://contextgarden.net

__= ___________________________________________________________________________= ______

 

= --_6E2C4B41-1080-4EA4-82D2-E853CD41F2E3_-- --===============7929118585830737099== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly90ZXguYWFuaGV0Lm5ldAphcmNoaXZlICA6IGh0dHA6Ly9mb3VuZHJ5LnN1cGVsZWMu ZnIvcHJvamVjdHMvY29udGV4dHJldi8Kd2lraSAgICAgOiBodHRwOi8vY29udGV4dGdhcmRlbi5u ZXQKX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX18= --===============7929118585830737099==--