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 25749 invoked from network); 23 Aug 2023 23:06:37 -0000 Received: from cgl.ntg.nl (5.39.185.202) by inbox.vuxu.org with ESMTPUTF8; 23 Aug 2023 23:06:37 -0000 Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 98251482C79 for ; Thu, 24 Aug 2023 01:05:32 +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 K8avylNvUUv9 for ; Thu, 24 Aug 2023 01:05:32 +0200 (CEST) Received: from cgl.ntg.nl (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 38902482CDF for ; Thu, 24 Aug 2023 01:04:42 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 1C6B1482BC3 for ; Thu, 24 Aug 2023 01:04:16 +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 L0e90pmhxyDR for ; Thu, 24 Aug 2023 01:04:15 +0200 (CEST) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 8E82E482BC2 for ; Thu, 24 Aug 2023 01:04:15 +0200 (CEST) Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-3ff1c397405so10264815e9.3 for ; Wed, 23 Aug 2023 16:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692831855; x=1693436655; h=message-id:in-reply-to:to:references:date:subject:mime-version:from :from:to:cc:subject:date:message-id:reply-to; bh=Z6ZOeAXPeLRT1LSRvgqijjSgFmwUFFYM0PMDgYKzLAs=; b=atKJDlHemb1I6NcFWItbFsaaqPBvzki5XmpQXN2YzjfusplbYMXsSG661rleCcwwA8 LuHd2XXseJ7tsijcHeCPrNzSt6vfDruyME++MWgzacE0f8nEyz/OjrFp78EceJtKELXB gIGUZeX+TcjhkqpVx0pcF9FCaJpcxUYapmBTHcqDsA5Y6ZNQHjyA04g4nII/ZhKA49HU PMij/g8OB0jAXI0cBwPq5MpaNX1Iu2iV9jCi++TTCRZWcaCUPq7iDhcozPjdfF36XtcT 3t2nqAjqagmvtaB2jvMB7cM0bQYPdGVrmS0FJUyF5W+U8ZyU4d7MwNNwLS3vGZRt8rA1 okiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692831855; x=1693436655; h=message-id:in-reply-to:to:references:date:subject:mime-version:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Z6ZOeAXPeLRT1LSRvgqijjSgFmwUFFYM0PMDgYKzLAs=; b=eHPVmJR794HdB+adJIZa5G7PFnS4ZQ8SU65YHzyFm/4vL4zVohECIPDOBmgw+RroXU NH6Hzc7TzGh/9u7Mq7QJCqimpjYrTBQUwW96Nv4XSvWERd7s/MIp4+Tt51446K26Jmog 6PeaP6t/Oa6iXLXOxO9ThxPBrdt/4ydMFCOtTO94krBCFSS489PCYRK+FjBwS0wQkc6r ncEyuDxTdItj4c2nxAmSoQoy3gdhwehJLnEGUQ/OBEmvX771nsiQPX+zSdN9nIL3fDEp mqj0zE4Xb4QELBHvM6fzSBgOv5AlLCfUj6e9JNtkvA3UAcgxTt9pnrV80Q5EKxhilWlu F0QQ== X-Gm-Message-State: AOJu0YzNvXHykKQl7YyAK+snzj9XYa+KzVJMQREyNspFf6QqETurtdV6 p8yHS/4MK7Xo4PQTlppCI3pIeRlWmxdizw== X-Google-Smtp-Source: AGHT+IGngjiLBGhGFKq3dH5u/mTx5IdTuM0kRVI6g7JbZjvEHlN546oP5luKVVPv6v9L6iXPtrG+MA== X-Received: by 2002:a5d:5962:0:b0:319:7b96:a1be with SMTP id e34-20020a5d5962000000b003197b96a1bemr8738723wri.71.1692831854854; Wed, 23 Aug 2023 16:04:14 -0700 (PDT) Received: from smtpclient.apple (2a01cb00879d240040f49a91177e949c.ipv6.abo.wanadoo.fr. [2a01:cb00:879d:2400:40f4:9a91:177e:949c]) by smtp.gmail.com with ESMTPSA id y17-20020adfe6d1000000b003176eab8868sm20342123wrm.82.2023.08.23.16.04.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2023 16:04:14 -0700 (PDT) From: Otared Kavian Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Date: Thu, 24 Aug 2023 01:04:13 +0200 References: To: mailing list for ConTeXt users In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.3654.120.0.1.15) Message-ID-Hash: HOJQEPYKT7AZ53EXNPAOTJOAPM7J5X6Q X-Message-ID-Hash: HOJQEPYKT7AZ53EXNPAOTJOAPM7J5X6Q X-MailFrom: otared@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="===============8484159688645476261==" --===============8484159688645476261== Content-Type: multipart/alternative; boundary="Apple-Mail=_DAB592A4-AD5A-4102-98BE-0A6E05514266" --Apple-Mail=_DAB592A4-AD5A-4102-98BE-0A6E05514266 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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: %% begin filling-with-lua.tex \starttext \startluacode context.startxtable{ align =3D "middle,lohi", bodyfont =3D "9pt", = framecolor =3D "black" } context.startxrow{ background =3D "color", backgroundcolor =3D = "lightgray" } 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 context.stopxtable() \stopluacode \stoptext %% end filling-with-lua.tex Best regards: Otared > On 23 Aug 2023, at 17:48, Wolfgang Schuster = wrote: >=20 > Fabrice Couvreur schrieb am 23.08.2023 um 19:28: >> Hi, >> I'm trying to fill an array using lua. So far it works but then I = don't know if it's possible. >=20 > Where do you have problems (look into cld-mkiv.pdf for hins)? >=20 > \starttext >=20 > \startluacode > context.startxtable{ align =3D "middle,lohi", bodyfont =3D "9pt", = framecolor =3D "black" } > context.startxrow{ background =3D "color", backgroundcolor =3D = "lightgray" } > 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) > end > context.stopxcell() > end > context.stopxrow() > end > context.stopxtable() > \stopluacode >=20 > \stoptext >=20 > Wolfgang >=20 > = __________________________________________________________________________= _________ > If your question is of interest to others as well, please add an entry = to the Wiki! >=20 > 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 > = __________________________________________________________________________= _________ Otared Kavian e-mail: otared@gmail.com Phone: +33 6 88 26 70 95 --Apple-Mail=_DAB592A4-AD5A-4102-98BE-0A6E05514266 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii 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:

%% begin filling-with-lua.tex
\starttext

\startluacode
context.startxtable{ align =3D "middle,lohi", bodyfont =3D = "9pt", framecolor =3D "black" }
    = context.startxrow{ background =3D "color", backgroundcolor =3D = "lightgray" }
        = 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
context.stopxtable()
\stopluacode

\stoptext
%% end = filling-with-lua.tex

Best regards: Otared

On 23 Aug 2023, at 17:48, = Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> wrote:

Fabrice Couvreur = schrieb am 23.08.2023 um 19:28:
Hi,
I'm trying to = fill an=20 array using lua. So far it works but then I don't know if it's = possible.

Where do you have problems (look into cld-mkiv.pdf for hins)?

\starttext

\startluacode
context.startxtable{ align =3D "middle,lohi", bodyfont =3D "9pt", = framecolor =3D "black" }
    context.startxrow{ background =3D "color", = backgroundcolor =3D=20 "lightgray" }
        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
=             &n= bsp;   context.startxcell()
=             &n= bsp;       if j =3D=3D 1 then
= =             &n= bsp;           = context(i)
=             &n= bsp;       end
=             &n= bsp;   context.stopxcell()
            = end
        context.stopxrow()
    end
context.stopxtable()
\stopluacode

\stoptext

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
_______________________________________________________________= ____________________

Otared Kavian
Phone: +33 6 88 26 70 95




= --Apple-Mail=_DAB592A4-AD5A-4102-98BE-0A6E05514266-- --===============8484159688645476261== 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 ___________________________________________________________________________________ --===============8484159688645476261==--