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

Can someone tell me what I'm doing wrong in the YODL?



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