From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1195 invoked by alias); 30 Jul 2014 14:16:48 -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: X-Seq: 19001 Received: (qmail 11398 invoked from network); 30 Jul 2014 14:16:45 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Date: Wed, 30 Jul 2014 16:10:31 +0200 From: Roman Neuhauser To: Peter Stephenson Cc: zsh-users@zsh.org Subject: Re: Repeat argument N times? Message-ID: <20140730141031.GC29163@isis.sigpipe.cz> References: <140729234830.ZM20800@torch.brasslantern.com> <20140730095657.6421d493@pwslap01u.europe.root.pri> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140730095657.6421d493@pwslap01u.europe.root.pri> User-Agent: Mutt/1.5.23 (2014-03-12) # p.stephenson@samsung.com / 2014-07-30 09:56:57 +0100: > On Tue, 29 Jul 2014 23:48:30 -0700 > Bart Schaefer wrote: > > There are other ways, e.g. > > > > upload-files file2(e{'repeat 10 reply+=($REPLY)'}) > > > > though the latter requires "file2" to actually exist, which sometimes > > might be a good thing. > > If you don't mind a limited repertoire of counts explicitly constructed, > you can make this method look close to what you want. > > % define-x() { eval "x$1() { typeset -ga reply; repeat $1 reply+=(\$REPLY) }" } > % define-x 3 > % print .zshrc(+x3) > .zshrc .zshrc .zshrc it looks like the alternative syntax permits generalization: function x { typeset -ga reply repeat $1 do reply+=($REPLY) done } print :)(e:x 3:) print :)(e:x 30:) -- roman