Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Repeat argument N times?



On Tue, 29 Jul 2014 23:48:30 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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

pws



Messages sorted by: Reverse Date, Date, Thread, Author