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 8122 invoked from network); 24 Aug 2023 19:44:55 -0000 Received: from cgl.ntg.nl (5.39.185.202) by inbox.vuxu.org with ESMTPUTF8; 24 Aug 2023 19:44:55 -0000 Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id C539F482BF4 for ; Thu, 24 Aug 2023 21:44:23 +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 w1az8-xe5yK7 for ; Thu, 24 Aug 2023 21:44:23 +0200 (CEST) Received: from cgl.ntg.nl (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 3D53F482CC4 for ; Thu, 24 Aug 2023 21:43:45 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 097E54824B3 for ; Thu, 24 Aug 2023 21:43:28 +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 Hu5vrDBFtSMr for ; Thu, 24 Aug 2023 21:43:27 +0200 (CEST) Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 AD85A4822C8 for ; Thu, 24 Aug 2023 21:43:27 +0200 (CEST) Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-313e742a787so171237f8f.1 for ; Thu, 24 Aug 2023 12:43:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692906207; x=1693511007; h=content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:from:to:cc:subject:date :message-id:reply-to; bh=/fEbhLGSipptgNQvc2fTt77n8HGkMs7KnafcqoC7eO0=; b=jKC+p3/NDANzmAFEb8wPahFQFpaR6iCS0GNH39v3RfaiwxS3g848Vs9uJw06Qqbi2m t2zmZrJ09wc2yDT4IUhJry+fPXVtYvuV0HWYAc8LwWxYAEMoYUURHP8YL2/eBsk8e39W XiIpWLLaYVNBWZVftCWs014Kg4WGBdXSQ5ouoAYl3YMEEs0YZ9jgJLWQFaG1mtK/dax5 zkqVJgxN27hh9Ai1J6PUGXB7SvoQadSLKwdKxN/cK3UkRkcNzsgVknOuic/kIY7L1uox 9uUNqAuyvowt8CEXHp287wZ/ny2wC/lCZt7nzrUwiQ7SmZMxzaTCCDf2pzAT3EJMzHul qMRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692906207; x=1693511007; h=content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=/fEbhLGSipptgNQvc2fTt77n8HGkMs7KnafcqoC7eO0=; b=bMP1rM7+7abGvyXQbLp43OnBYKPiWE8JWVJxnQvISynxdrtEOVdVOyVeEbG2kyKdCd kiK4Q5t1P77WvzEHjkGSZKvIHzBtlp+q/jcgmNms1bSIqIsdi66ypXfCU3MOY4SDnWDo nj28y/A5UIPGxyBI8YMWlX6tGkqgd9xRvbqVVcsc4QxpGKUDmuXGjb7KsajfGOF220bI snhWXz9xrH7UwzgRwHvBssksApZedIT8l5EymlsIIGeaDnlRvlFpBUe8k6QhMB/KUVv/ heRsl9LyCg9iaE1UJl5RE9HrY62og1T3gzj0Ja1JAbrCjHiJO+ktDzti+8T94BadMv++ SXQw== X-Gm-Message-State: AOJu0YxsRP5u0SoC5PLe73uqEk5EsR3se5ojTMZvZQuZiGYil1SYqzza Aetp5C8fhSeLjRg15jMlgN4qOWHaD3U= X-Google-Smtp-Source: AGHT+IGF1anidv/uD691t0sHlMnKuO3ZS86gGzmH0kX8s9GrTT0GnoV//DwmzzTqak1P17cWnGqK6Q== X-Received: by 2002:a5d:4d06:0:b0:31c:2f95:8056 with SMTP id z6-20020a5d4d06000000b0031c2f958056mr11600129wrt.23.1692906206968; Thu, 24 Aug 2023 12:43:26 -0700 (PDT) Received: from ?IPv6:2a02:810d:a8bf:fe08:bcc6:8b3c:9d05:bb0a? ([2a02:810d:a8bf:fe08:bcc6:8b3c:9d05:bb0a]) by smtp.gmail.com with ESMTPSA id y3-20020adfe6c3000000b0031c5ce91ad6sm53084wrm.97.2023.08.24.12.43.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Aug 2023 12:43:26 -0700 (PDT) To: Otared Kavian References: <81c7dc1a-c6e9-3b4e-abba-f9ac574aad2a@gmail.com> <0D8E23FE-0CC5-4D07-AD38-566AF5F7326A@gmail.com> From: Wolfgang Schuster Message-ID: Date: Thu, 24 Aug 2023 21:43:23 +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: <0D8E23FE-0CC5-4D07-AD38-566AF5F7326A@gmail.com> Content-Language: en-US Message-ID-Hash: B7OOGFEABPL5BCHC45GFEVMRPSRSPA2F X-Message-ID-Hash: B7OOGFEABPL5BCHC45GFEVMRPSRSPA2F 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 CC: mailing list for ConTeXt users 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="===============6496962136679241764==" This is a multi-part message in MIME format. --===============6496962136679241764== Content-Type: multipart/alternative; boundary="------------B93E7FC75587A89653771C8A" Content-Language: en-US This is a multi-part message in MIME format. --------------B93E7FC75587A89653771C8A Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Otared Kavian schrieb am 24.08.2023 um 12:50: > >> On 24 Aug 2023, at 06:03, Wolfgang Schuster >> > > wrote: >>> […] >> >> 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 > > Indeed this is much more elegant… It feels so good to be on this list > and learn from such insights :-) We don't even need the math.mod function because Lua added with version 5.1 a modulo operator, the loop to create the row can now be changed to     for i = 0,9 do         context.startxrow()             context.startxcell()                 context(i)             context.stopxcell()             context.startxcell()                 context(i * i % 10)             context.stopxcell()             context.startxcell()                 context(i)             context.stopxcell()             context.startxcell()                 context(2 * i * i % 10)             context.stopxcell()         context.stopxrow()     end Wolfgang --------------B93E7FC75587A89653771C8A Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Otared Kavian schrieb am 24.08.2023 um 12:50:

On 24 Aug 2023, at 06:03, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> wrote:
[…]

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

Indeed this is much more elegant… It feels so good to be on this list and learn from such insights :-)

We don't even need the math.mod function because Lua added with version 5.1 a modulo operator,
the loop to create the row can now be changed to

    for i = 0,9 do
        context.startxrow()
            context.startxcell()
                context(i)
            context.stopxcell()
            context.startxcell()
                context(i * i % 10)
            context.stopxcell()
            context.startxcell()
                context(i)
            context.stopxcell()
            context.startxcell()
                context(2 * i * i % 10)
            context.stopxcell()
        context.stopxrow()
    end

Wolfgang

--------------B93E7FC75587A89653771C8A-- --===============6496962136679241764== 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 ___________________________________________________________________________________ --===============6496962136679241764==--