From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 29ba9117 for ; Mon, 19 Aug 2019 06:21:18 +0000 (UTC) Received: (qmail 29174 invoked by alias); 19 Aug 2019 06:21:09 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24156 Received: (qmail 18184 invoked by uid 1010); 19 Aug 2019 06:21:09 -0000 X-Qmail-Scanner-Diagnostics: from mail-wr1-f50.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25545. spamassassin: 3.4.2. Clear:RC:0(209.85.221.50):SA:0(-0.1/5.0):. Processed in 4.516475 secs); 19 Aug 2019 06:21:09 -0000 X-Envelope-From: stephane.chazelas@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.221.50 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=1oyq6jjHC1huLvkHpLnei4ADSGe8AsTxJ0FqDDDNiRQ=; b=dSeOmDmvULp9K1HhtnSDp9AgMaG10tLsAWHHgx7wYmJXMv/aQT59e+AXaTjQ+NZ7c8 dJeX862ufRqyHWAZHDBy3+aXHJKPF5O3bjM4UK8OH2IFRV8epr/iBITX30YQ/vcITtvN ov+E2IJTrysKp/vb7bdQzesEmjXjJw473u1IAeV9e7/A+nxFvy/2RVyJuaDGsvsGJUz2 hnL3wxHYdI1467Ujoue3F8/Z9m934vmYqZWCxBSxdL9aljJu9dKweQvuaQjz2xlwuuR2 t6lQgFgRD22wXqB6wij5uDsEznSwy8ZW4MIBmvkYInqdzLMGkGKhZ4vwFv3Q6X5v5O5j rTmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=1oyq6jjHC1huLvkHpLnei4ADSGe8AsTxJ0FqDDDNiRQ=; b=CD0Oup4I/vzASSObgDktkV1s3+RrbkG3Tuc2Ci5EjlWAU0Id2DkBCkWI2iHu923dDu L699XdE9y035M2CzMWH3cNQbm4GbMfdQqnQjdyutDwl7Qnk5KRN1WcXS6vHffMLo2trI B6vmVGh9dGX1zzAAr1XMY064QHkmZ8v2GHxrO7ULkLrHCXUawaI3JniBPjPgnv8Us9Y1 qcx6GtrwXuNlS+z+jI7CrpNAybHK/3FSFa166DopoW+tBL756AC+qd600pI7G/1GwR8V 3FfQ19KjbjpQJIL6tDCEq6kyO0KZqnxW89nR+b/IkNxsQxZCDbk45OLzQkcY5WMOL482 0hqQ== X-Gm-Message-State: APjAAAWa+vfUxzk48pZmyzSIhuubTSqHMGyxPm6wa+xKJD/v/s8cnSR/ IqELEcmJBBcQ5BTkkIH3MhA= X-Google-Smtp-Source: APXvYqzGungxAwPu2IW+O8ZsiZwRdF8qPO/55jfkgTC/PeIbZlaXYa60rGb0jI6g70xamAXrvBCQ/g== X-Received: by 2002:a5d:5408:: with SMTP id g8mr17847041wrv.201.1566195630553; Sun, 18 Aug 2019 23:20:30 -0700 (PDT) Date: Mon, 19 Aug 2019 07:20:28 +0100 From: Stephane Chazelas To: Sebastian Gniazdowski Cc: Zsh Users Subject: Re: Can you loop in math mode? Message-ID: <20190819062028.dkewms2nxt37o4te@chaz.gmail.com> Mail-Followup-To: Sebastian Gniazdowski , Zsh Users References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 2019-08-19 02:16:20 +0200, Sebastian Gniazdowski: [...] > is some kind of a looping possible in math mode? [...] Can you maybe be more specific as to what you're trying to do? You can use recursion: $ n=6 a='(n-->1 ? a*(n+1) : 1)' zsh -c 'echo $((a))' 720 (6!) Including via math functions, but within limits. $ n=0 a='(++n <= 255 ? a+2 : 1)' zsh -c 'echo $((a))' zsh:1: math recursion limit exceeded: (++n <= 255 ? a+2 : 1) And you can of course have command substitutions inside an arithmetic expression: $ echo $(( 1 $(for i ({2..6}) print "*$i") )) 720 -- Stephane