From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, URIBL_SBL_A autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 15686 invoked from network); 24 Aug 2023 09:17:14 -0000 Received: from cgl.ntg.nl (5.39.185.202) by inbox.vuxu.org with ESMTPUTF8; 24 Aug 2023 09:17:14 -0000 Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id D229F482CDC for ; Thu, 24 Aug 2023 11:16:14 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at cgl.ntg.nl Received: from cgl.ntg.nl ([127.0.0.1]) by localhost (cgl.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 829lxr4Jfb_x for ; Thu, 24 Aug 2023 11:16:14 +0200 (CEST) Received: from cgl.ntg.nl (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id DF882482D6B for ; Thu, 24 Aug 2023 11:15:14 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 1D3184828E8 for ; Thu, 24 Aug 2023 11:14:50 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at cgl.ntg.nl Received: from cgl.ntg.nl ([127.0.0.1]) by localhost (cgl.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jHQwyTmZcvDE for ; Thu, 24 Aug 2023 11:14:49 +0200 (CEST) Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cgl.ntg.nl (Postfix) with ESMTPS id 99ADF482898 for ; Thu, 24 Aug 2023 11:14:49 +0200 (CEST) Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-52a23227567so2694654a12.0 for ; Thu, 24 Aug 2023 02:14:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692868489; x=1693473289; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=xGv3jDH9EGRDU7BFnnn86zAjna4bEKGZMI2GKW255ns=; b=WRYXITwSgyugNlQTI4xJzYw2ceBPwzHTp+u9A2VSJo5rFW/LeFF64+zFxqmVBuDw4W LigY8mmzdnV1FYFhHqKCdE4NM6LWoqEOMRD2rP6IWp6TCrZu6pcWYXKq0ao3odYD0zi7 LYgukyF2RgEeVxZ/UVvlkfM+Io6l9aGZxg9E7/23tpJvpZF86d+J48IIPXNtTXZfcejR XtyPtrwhzY1E7lIz2ooMJGzvn2zolBPOmqQlNCrAouNQCwdA+dsxYs9G68SRdrmyn95s CpXrEZa9J1IvQcBSrVR87OXEZoERGqh8RvbH/H+iB2raD8sG0KJ3fnGGMz4+rVzDA478 a1kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692868489; x=1693473289; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xGv3jDH9EGRDU7BFnnn86zAjna4bEKGZMI2GKW255ns=; b=Bq/nAWG3eoeI3qA4wyea0RJAI9BR8gjVMTN70kvfDiFhYqR7pROtAIitsK9pDOzuC7 P1il8uPi2ckAssT0Nm/qWwMJFCVDCLPS/UbrNksDu9/IJAOqp/0kcgGpCjZ8RqMPhGH2 cZELXXD/DRFRagq71w9J4+mxW66wnI5VwecBfOlFPlJQFd245TEV7yn0CMCYCjl50gxc U+3cA4khHpgYGp5aL2ao0ZNdkjOu9Q1SXIgEdE4V1uNIalA96yepVe2rdp2N8IZ+0aqw tf0BeUYFDfx4EC6eKByCnO+8eOTMCWN9pdsUJE0pafAloUQ+LRykEx6O5pXlF5XroJqp ZPZw== X-Gm-Message-State: AOJu0Yzkkbmhyv3gmTc32Ob0pFyWyLByTWZhtC7WWGNCbAz0F4Z3/gih yJmf7XhSPuWf3ivaXuWflBFLZMhQRj4m68zn+RViD7dRelw= X-Google-Smtp-Source: AGHT+IFRgDUqjTAx7K5VSXHQxdBoftkYLlcKiB5pTFQdk8aXpKauF2MqRE0EI2pkb9dhHQ0+C2g2wu1SnWTqf/7iItY= X-Received: by 2002:a05:6402:2025:b0:521:ae63:ee63 with SMTP id ay5-20020a056402202500b00521ae63ee63mr12359828edb.16.1692868488800; Thu, 24 Aug 2023 02:14:48 -0700 (PDT) MIME-Version: 1.0 References: <81c7dc1a-c6e9-3b4e-abba-f9ac574aad2a@gmail.com> In-Reply-To: <81c7dc1a-c6e9-3b4e-abba-f9ac574aad2a@gmail.com> From: Fabrice Couvreur Date: Thu, 24 Aug 2023 11:15:47 +0000 Message-ID: To: mailing list for ConTeXt users Message-ID-Hash: ZOYNFTG7JMHXJDXCRKFNCJVV3NQHOMEW X-Message-ID-Hash: ZOYNFTG7JMHXJDXCRKFNCJVV3NQHOMEW X-MailFrom: fabrice1.couvreur@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list Reply-To: mailing list for ConTeXt users Subject: [NTG-context] Re: Question about building an array of values with Lua List-Id: mailing list for ConTeXt users Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: multipart/mixed; boundary="===============6138560592957185703==" --===============6138560592957185703== Content-Type: multipart/alternative; boundary="000000000000ed30170603a7a894" --000000000000ed30170603a7a894 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Otared and Wolgang, Thanks for the answers. In fact, being familiar with Python and not at all with Lua, I didn't have the reflex to think of using a mathematical function which gives the remainder in the Euclidean division by 10, it's strange !! Fabrice Le jeu. 24 ao=C3=BBt 2023 =C3=A0 04:06, Wolfgang Schuster < wolfgang.schuster.lists@gmail.com> a =C3=A9crit : > Otared Kavian schrieb am 24.08.2023 um 01:04: > > Hi Fabrice, > > As Wolfgang points out, it is indeed possible to fill-in your table with > Lua: maybe you were wondering how to fill the columns 2, 3 and 4. In this > case you need to use the Lua function math.mod as in the following, which > is a completed version of what Wolfgang sent: > > > I guess I completely missed the units digit part :) > > %% begin filling-with-lua.tex > \starttext > > \startluacode > context.startxtable{ align =3D "middle,lohi", bodyfont =3D "9pt", frameco= lor =3D > "black" } > context.startxrow{ background =3D "color", backgroundcolor =3D "light= gray" > } > context.startxcell{ nx =3D 4 } > context("Units digit of") > context.stopxcell() > context.stopxrow() > context.startxrow() > context.startxcell{ width =3D "1cm" } > context.im("a") > context.stopxcell() > context.startxcell{ width =3D "1cm" } > context.im("a^2") > context.stopxcell() > context.startxcell{ width =3D "1cm" } > context.im("b") > context.stopxcell() > context.startxcell{ width =3D "1cm" } > context.im("2b^2") > context.stopxcell() > context.stopxrow() > for i =3D 0,9 do > context.startxrow() > for j =3D 1,4 do > context.startxcell() > if j =3D=3D 1 then > context(i) > elseif j =3D=3D 2 then > context(math.mod(i*i,10)) > elseif j =3D=3D 3 then > context(i) > else > context(math.mod(2*i*i,10)) > end > context.stopxcell() > end > context.stopxrow() > end > > > I would drop the column check in this case. > > for i =3D 0,9 do > context.startxrow() > context.startxcell() > context(i) > context.stopxcell() > context.startxcell() > context(math.mod(i*i,10)) > context.stopxcell() > context.startxcell() > context(i) > context.stopxcell() > context.startxcell() > context(math.mod(2*i*i,10)) > context.stopxcell() > context.stopxrow() > end > > Wolfgang > > > _________________________________________________________________________= __________ > If your question is of interest to others as well, please add an entry to > the Wiki! > > maillist : ntg-context@ntg.nl / > https://www.ntg.nl/mailman/listinfo/ntg-context > webpage : https://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : https://contextgarden.net > > _________________________________________________________________________= __________ --000000000000ed30170603a7a894 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Otared and Wolgang,
Thanks for the answers. In fact, bein= g familiar with Python and not at all with Lua, I didn't have the refle= x to think of using a mathematical function which gives the remainder in th= e Euclidean division by 10, it's strange !!
Fabrice

=
Le=C2=A0je= u. 24 ao=C3=BBt 2023 =C3=A0=C2=A004:06, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> a =C3=A9crit=C2=A0:
Otared Kavian schrieb am 24.08.2023 um 01:04:
=20 Hi Fabrice,

As Wolfgang points out, it is indeed possible to fill-in your table with Lua: maybe you were wondering how to fill the columns=20 2, 3 and 4. In this case you need to use the Lua function math.mod as in the following, which is a completed version of what Wolfgang sent:

I guess I completely missed the units digit part :)

%% begin fil= ling-with-lua.tex
\starttext

\startluacode
con= text.startxtable{ align =3D=20 "middle,lohi", bodyfont =3D "9pt", framecolor =3D "= ;black" }
=C2=A0 =C2=A0 context.startxrow{ background =3D &q= uot;color", backgroundcolor =3D=20 "lightgray" }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 context.start= xcell{ nx =3D 4 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 conte= xt("Units digit of")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 context.stopxcell()
=C2=A0 =C2=A0 context.stopxrow()
=C2=A0 =C2=A0 context.startxrow()
=C2=A0 =C2=A0 =C2=A0 =C2= =A0=20 context.startxcell{ width =3D "1cm" }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 context.stopxcell()
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 context.startxcell{ width =3D "1cm" }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 context.im("a^2")
=C2=A0 =C2=A0 =C2=A0 =C2= =A0=20 context.stopxcell()
=C2=A0 =C2=A0 =C2=A0 =C2=A0 context.startxcel= l{ width =3D "1cm" }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = context.im("b"= ;)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 context.stopxcell()
=C2= =A0 =C2=A0 =C2=A0 =C2=A0=20 context.startxcell{ width =3D "1cm" }
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0=20 context.im("2b^2&q= uot;)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 context.stopxcell()
= =C2=A0 =C2=A0 context.stopxrow()
=C2=A0 =C2=A0 for i =3D 0,9 do
=C2=A0 =C2=A0 =C2=A0 =C2=A0 context.startxrow()
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for j =3D 1,4 do
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 context.startxcell()
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if j =3D=3D 1 then
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 context(i)
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 elseif j =3D=3D 2 then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 context(m= ath.mod(i*i,10))
=C2=A0elseif j =3D=3D 3 then
=C2=A0 context(i)
=C2=A0else
=C2=A0 context(math.mod(2*i*i,= 10))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 end
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0=20 context.stopxcell()
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 end=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 context.stopxrow()
=C2=A0 = =C2=A0 end

I would drop the column check in this case.

=C2=A0=C2=A0=C2=A0 for i =3D 0,9 do
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 context.startxrow()
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 context.= startxcell()
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 context(i)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 context.= stopxcell()
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 context.= startxcell()
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 context(math.mod(i*i,10))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 context.= stopxcell()
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 context.= startxcell()
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 context(i)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 context.= stopxcell()
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 context.= startxcell()
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 context(math.mod(2*i*i,10))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 context.= stopxcell()
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 context.stopxrow()
=C2=A0=C2=A0=C2=A0 end

Wolfgang

___________________________________________________________________________= ________
If your question is of interest to others as well, please add an entry to t= he Wiki!

maillist : ntg-cont= ext@ntg.nl / https://www.ntg.nl/mailman/listinfo/= ntg-context
webpage=C2=A0 : https://www.pragma-ade.nl / http://context.aanhet.net
archive=C2=A0 :
https://bitbucket.org/phg/context-m= irror/commits/
wiki=C2=A0 =C2=A0 =C2=A0: https://contextgarden.net
___________________________________________________________________________= ________
--000000000000ed30170603a7a894-- --===============6138560592957185703== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___________________________________________________________________________________ --===============6138560592957185703==--