Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Can someone tell me what I'm doing wrong in the YODL?
- X-seq: zsh-workers 52799
- From: Clinton Bunch <cdb_zsh@xxxxxxxxxxx>
- To: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Can someone tell me what I'm doing wrong in the YODL?
- Date: Sat, 23 Mar 2024 16:09:30 -0500
- Archived-at: <https://zsh.org/workers/52799>
- List-id: <zsh-workers.zsh.org>
This is the relevant YODL:
This is to facilitate a construct like example($a[zrand_int($#a)+1]) rather
than example($a[zrand_int+LPAR()$#a-1+RPAR()+1]).
Since example(zrand_int+LPAR()16RPAR()) has 16
possible return values 0-15, in order to use it as an array index which goes
from 1-16 you need to add one since it can return zero. So you don't want it
to return 16.
This is the resultant section of man page:
This is to facilitate a construct like .RS
$a[zrand_int($#a)+1]
than .RS
$a[zrand_int($#a-1)+1]
Since .RS
zrand_int(16)
possible return values 0-15, in order to use it as an array
index which
goes from 1-16 you need to add one since it can return zero.
So you
don't want it to return 16.
This is on Rocky Linux 8 (RHEL derivative)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author