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 4339 invoked from network); 24 Aug 2023 04:05:06 -0000 Received: from cgl.ntg.nl (5.39.185.202) by inbox.vuxu.org with ESMTPUTF8; 24 Aug 2023 04:05:06 -0000 Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 23882482CAB for ; Thu, 24 Aug 2023 06:04:40 +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 RsVO4Rnk-e8T for ; Thu, 24 Aug 2023 06:04:39 +0200 (CEST) Received: from cgl.ntg.nl (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 83BE2482CC8 for ; Thu, 24 Aug 2023 06:03:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 650C7482A2B for ; Thu, 24 Aug 2023 06:03:40 +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 7MxuHjLOYODE for ; Thu, 24 Aug 2023 06:03:39 +0200 (CEST) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 E993C4829F4 for ; Thu, 24 Aug 2023 06:03:39 +0200 (CEST) Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-3fee5ddc23eso47237465e9.1 for ; Wed, 23 Aug 2023 21:03:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692849819; x=1693454619; h=content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:from:to:cc:subject:date :message-id:reply-to; bh=ZPTj6cO/8wyxqHDqrUtyvm1xDa7xOvL0o+dLe9vp3OA=; b=og+B6rrchjSIMIaRaEwQmQKK+T5OIZXoH49l8DpFWH1HHLsHqkONKO9FaAcC8HEaED bkzx/KJRQXk2vYlUeH0msd7P69Z5lqjQAk+jvvosVdIldi+2pU3RRHnREzyvd08e9hQm p0KESybqOhkUOSL0WeZjJ7ZV/mkcc0sg5wAqngZxaxK+fF5CxHRTv8t5/27/8SgaMBhr YXfbYQRZCUDaqgpAiQHOZ2HFJT8OQflOp0v8KAoTlysReRQHUuRRfI8IXNCZrAGQu33y putBH6IEYUbW9D0lqCdC6rVLM7nTsCA92mu6KTbLIgSPFP4L2iQqgNq7yVzW89z3EjzM +PWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692849819; x=1693454619; h=content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZPTj6cO/8wyxqHDqrUtyvm1xDa7xOvL0o+dLe9vp3OA=; b=CLOxtDbufr8KJRm6mM2kSES7xCogTVlWDVkuxSPOzX4e3i4Qy0NMQaaOFThAxb6SYn ltIceMJKy0H+cfDZpyfMPkQqXcANg1apiJM/wMRAUgp3eoCroZT2XPOTxVOw5OKzM+Rt gfyJOfxe1gaPYv6kGmNTF/cAN1zg5uUBgjWcHpB2Cvdbq9jX8m4+pCoDdwevpiW/8lCU dEQbs9XAiw/W8r/3bQKu/gk3945AeKS+9sBmwzjsUk3xQeXhHgK4FmwzUiyzBm4qkbz+ m8WD1gw7szYMzJMPjznl32PY9oGgtYURIVYkognHP5/wlkgpKrrn9lsYRL/G3dlQ9Sv0 VQGw== X-Gm-Message-State: AOJu0YwpZ6XWl+tU1+uxGra5obzJu9BIhirj3/2E271eW05T2geirh5v SVnWoWxvgWVjoK3MhUJm5IA= X-Google-Smtp-Source: AGHT+IHIG92CPMXl4KUNxwE89UOSEbItOZR9aaN3tcU1/mlwceQL/Bjt4VhYuq+JS0z9+SfGWamjEQ== X-Received: by 2002:a1c:6a16:0:b0:3fa:98c3:7dbd with SMTP id f22-20020a1c6a16000000b003fa98c37dbdmr10976530wmc.41.1692849819206; Wed, 23 Aug 2023 21:03:39 -0700 (PDT) Received: from ?IPv6:2a02:810d:a8bf:fe08:4c40:b58f:41d7:1ac3? ([2a02:810d:a8bf:fe08:4c40:b58f:41d7:1ac3]) by smtp.gmail.com with ESMTPSA id u11-20020a05600c210b00b003fe2b081661sm1258976wml.30.2023.08.23.21.03.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2023 21:03:38 -0700 (PDT) To: mailing list for ConTeXt users , Otared Kavian References: From: Wolfgang Schuster Message-ID: <81c7dc1a-c6e9-3b4e-abba-f9ac574aad2a@gmail.com> Date: Thu, 24 Aug 2023 06:03:36 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 PostboxApp/7.0.60 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Message-ID-Hash: ETFBB52HZ6Z6YT55WGAOQXWDL7VSLYZ7 X-Message-ID-Hash: ETFBB52HZ6Z6YT55WGAOQXWDL7VSLYZ7 X-MailFrom: wolfgang.schuster.lists@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="===============7913338560788898625==" This is a multi-part message in MIME format. --===============7913338560788898625== Content-Type: multipart/alternative; boundary="------------6CA5D1E4A1C09304A80C6349" Content-Language: en-US This is a multi-part message in MIME format. --------------6CA5D1E4A1C09304A80C6349 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit 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 = "middle,lohi", bodyfont = "9pt", > framecolor = "black" } >     context.startxrow{ background = "color", backgroundcolor = > "lightgray" } >         context.startxcell{ nx = 4 } >             context("Units digit of") >   context.stopxcell() >     context.stopxrow() >     context.startxrow() > context.startxcell{ width = "1cm" } > context.im("a") >         context.stopxcell() >         context.startxcell{ width = "1cm" } >           context.im("a^2") > context.stopxcell() >         context.startxcell{ width = "1cm" } >             context.im("b") >         context.stopxcell() > context.startxcell{ width = "1cm" } > context.im("2b^2") >         context.stopxcell() >     context.stopxrow() >     for i = 0,9 do >         context.startxrow() >             for j = 1,4 do >                 context.startxcell() >                     if j == 1 then >               context(i) >                     elseif j == 2 then > context(math.mod(i*i,10)) >  elseif j == 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 = 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 --------------6CA5D1E4A1C09304A80C6349 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: 8bit 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 = "middle,lohi", bodyfont = "9pt", framecolor = "black" }
    context.startxrow{ background = "color", backgroundcolor = "lightgray" }
        context.startxcell{ nx = 4 }
            context("Units digit of")
        context.stopxcell()
    context.stopxrow()
    context.startxrow()
        context.startxcell{ width = "1cm" }
            context.im("a")
        context.stopxcell()
        context.startxcell{ width = "1cm" }
            context.im("a^2")
        context.stopxcell()
        context.startxcell{ width = "1cm" }
            context.im("b")
        context.stopxcell()
        context.startxcell{ width = "1cm" }
            context.im("2b^2")
        context.stopxcell()
    context.stopxrow()
    for i = 0,9 do
        context.startxrow()
            for j = 1,4 do
                context.startxcell()
                    if j == 1 then
                        context(i)
                    elseif j == 2 then
                    context(math.mod(i*i,10))
 elseif j == 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 = 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

--------------6CA5D1E4A1C09304A80C6349-- --===============7913338560788898625== 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 ___________________________________________________________________________________ --===============7913338560788898625==--