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

Re: [PATCH 0/1] zsh/random module



On Tue, Mar 26, 2024 at 5:47 AM Clinton Bunch <cdb_zsh@xxxxxxxxxxx> wrote:
>
> Does this work better:
>
> tt(inclusive) is a flag that controls whether the result is ever equal to
> tt(upper).  By default it is not. If this argument is set to a non-zero
> value
> then it may be.

Fine.

> For example, if $#a is 16, you would use tt(zrand_int+LPAR()16RPAR())
> which 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.  Because the function can return zero, it
> would
> be an array index range error for it to also potentially return 16
> ($#a).

I probably spot-checked this one incorrectly.  I was looking for something like:

 ... which has 16 possible return values 0-15.  Because the function can return
 zero, in order to use it as an array index from 1-16 you need to add one.  It
 would be an array index range error for it to also potentially return 16
 (tt($#a)).

> You
> could, however, use the construct tt(zrand_int+LPAR()16,1,1+RPAR())
> instead of
> adding 1 to achieve the same result, but it is more verbose.

Sure.

> Most statistics algorithms seem to also expect 0 to tt(upper)-1, so this was
> deemed the most commonly desired case and chosen as the default.

Also fine.




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