* How to generate a list of numbers without 'seq'?
@ 2004-03-18 20:52 DervishD
2004-03-18 21:12 ` Clint Adams
0 siblings, 1 reply; 7+ messages in thread
From: DervishD @ 2004-03-18 20:52 UTC (permalink / raw)
To: Zsh Users
Hi all :)
I want to generate (well, I don't want, is just curiosity) a list
of numbers in the shell but without using 'seq'. Namely, I want this
command (just an example):
print -l `seq 0 10`
entirely using Zsh. How can I replace the 'seq'???
Thanks in advance ;))
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to generate a list of numbers without 'seq'?
2004-03-18 20:52 How to generate a list of numbers without 'seq'? DervishD
@ 2004-03-18 21:12 ` Clint Adams
2004-03-19 9:58 ` DervishD
0 siblings, 1 reply; 7+ messages in thread
From: Clint Adams @ 2004-03-18 21:12 UTC (permalink / raw)
To: Zsh Users
> print -l `seq 0 10`
>
> entirely using Zsh. How can I replace the 'seq'???
print -l {0..10}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to generate a list of numbers without 'seq'?
2004-03-18 21:12 ` Clint Adams
@ 2004-03-19 9:58 ` DervishD
2004-03-19 16:34 ` Dan Nelson
0 siblings, 1 reply; 7+ messages in thread
From: DervishD @ 2004-03-19 9:58 UTC (permalink / raw)
To: Clint Adams; +Cc: Zsh Users
Hi Clint :)
* Clint Adams <clint@zsh.org> dixit:
> > print -l `seq 0 10`
> > entirely using Zsh. How can I replace the 'seq'???
> print -l {0..10}
This is more similar to the solution I was trying using <X-Y>,
which doesn't seem to work if it cannot be expanded :( But IIRC, I've
used <X-Y> syntax to generate list of numbers, but I don't remember
how, when, etc.
BTW I missed the {N1..N2} syntax under brace expansion O:)
Thanks a lot for your answer :)
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to generate a list of numbers without 'seq'?
2004-03-19 9:58 ` DervishD
@ 2004-03-19 16:34 ` Dan Nelson
2004-03-20 10:00 ` DervishD
0 siblings, 1 reply; 7+ messages in thread
From: Dan Nelson @ 2004-03-19 16:34 UTC (permalink / raw)
To: Clint Adams, Zsh Users
In the last episode (Mar 19), DervishD said:
> Hi Clint :)
>
> * Clint Adams <clint@zsh.org> dixit:
> > > print -l `seq 0 10`
> > > entirely using Zsh. How can I replace the 'seq'???
> > print -l {0..10}
>
> This is more similar to the solution I was trying using <X-Y>,
> which doesn't seem to work if it cannot be expanded :( But IIRC, I've
> used <X-Y> syntax to generate list of numbers, but I don't remember
> how, when, etc.
<x-y> is pattern matching, so it only matches existing filenames;
{x..y} is parameter expansion so it generates its own values. If you
have a LOT of numbers you want to generate, {x..y} will suck up memory,
so incrementing and printing a counter variable in a loop is better.
--
Dan Nelson
dnelson@allantgroup.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to generate a list of numbers without 'seq'?
2004-03-19 16:34 ` Dan Nelson
@ 2004-03-20 10:00 ` DervishD
2004-03-21 3:54 ` Dan Nelson
0 siblings, 1 reply; 7+ messages in thread
From: DervishD @ 2004-03-20 10:00 UTC (permalink / raw)
To: Dan Nelson; +Cc: Clint Adams, Zsh Users
Hi Dan :)
* Dan Nelson <dnelson@allantgroup.com> dixit:
> > > print -l {0..10}
> > This is more similar to the solution I was trying using <X-Y>,
> > which doesn't seem to work if it cannot be expanded :( But IIRC, I've
> > used <X-Y> syntax to generate list of numbers, but I don't remember
> > how, when, etc.
> <x-y> is pattern matching, so it only matches existing filenames;
Is there a way of making it work in string environment or
something like that (a mechanism similar to the use of globbing flags
in pattern matching at parameter expansion)?
> {x..y} is parameter expansion so it generates its own values. If
> you have a LOT of numbers you want to generate, {x..y} will suck up
> memory, so incrementing and printing a counter variable in a loop
> is better.
So for general use, when you don't know in advance how many
numbers you want to generate, is better to use the variable in a
loop.
Thanks for the information :))
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to generate a list of numbers without 'seq'?
2004-03-20 10:00 ` DervishD
@ 2004-03-21 3:54 ` Dan Nelson
2004-03-21 12:06 ` DervishD
0 siblings, 1 reply; 7+ messages in thread
From: Dan Nelson @ 2004-03-21 3:54 UTC (permalink / raw)
To: Clint Adams, Zsh Users
In the last episode (Mar 20), DervishD said:
> Dan Nelson <dnelson@allantgroup.com> dixit:
> > > > print -l {0..10}
> > > This is more similar to the solution I was trying using <X-Y>,
> > > which doesn't seem to work if it cannot be expanded :( But IIRC, I've
> > > used <X-Y> syntax to generate list of numbers, but I don't remember
> > > how, when, etc.
> > <x-y> is pattern matching, so it only matches existing filenames;
>
> Is there a way of making it work in string environment or
> something like that (a mechanism similar to the use of globbing flags
> in pattern matching at parameter expansion)?
It should work any time zsh does pattern matching:
$ [[ 4 == <1-5> ]] && echo yes || echo no
yes
$ [[ 6 == <1-5> ]] && echo yes || echo no
no
including case statements and ${var%%pattern} searches.
--
Dan Nelson
dnelson@allantgroup.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to generate a list of numbers without 'seq'?
2004-03-21 3:54 ` Dan Nelson
@ 2004-03-21 12:06 ` DervishD
0 siblings, 0 replies; 7+ messages in thread
From: DervishD @ 2004-03-21 12:06 UTC (permalink / raw)
To: Dan Nelson; +Cc: Clint Adams, Zsh Users
Hi Dan :)
* Dan Nelson <dnelson@allantgroup.com> dixit:
> > Is there a way of making it work in string environment or
> > something like that (a mechanism similar to the use of globbing flags
> > in pattern matching at parameter expansion)?
> It should work any time zsh does pattern matching:
[...]
> including case statements and ${var%%pattern} searches.
I knew that, but I thought it could be used to generate numbers.
Obviously, I didn't recall correctly :) Thanks for all your help :)
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-03-21 12:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-18 20:52 How to generate a list of numbers without 'seq'? DervishD
2004-03-18 21:12 ` Clint Adams
2004-03-19 9:58 ` DervishD
2004-03-19 16:34 ` Dan Nelson
2004-03-20 10:00 ` DervishD
2004-03-21 3:54 ` Dan Nelson
2004-03-21 12:06 ` DervishD
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).