zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Clinton Bunch <cdb_zsh@zentaur.org>
Cc: zsh-workers@zsh.org
Subject: Re: [PATCH 0/1] zsh/random module
Date: Tue, 26 Mar 2024 11:25:44 -0700	[thread overview]
Message-ID: <CAH+w=7YcN=LW-qErK+4Xm=YckgwMRtvO1XKYvW+j5Jgho+fHnw@mail.gmail.com> (raw)
In-Reply-To: <e7c5eb5e-2f2f-4ef6-acdf-124490958a66@zentaur.org>

On Tue, Mar 26, 2024 at 5:47 AM Clinton Bunch <cdb_zsh@zentaur.org> 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.


  parent reply	other threads:[~2024-03-26 18:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-24 14:11 Clinton Bunch
2024-03-25  2:34 ` Bart Schaefer
2024-03-26 12:47   ` Clinton Bunch
2024-03-26 13:01     ` Clinton Bunch
2024-03-26 18:25     ` Bart Schaefer [this message]
2024-04-06  2:41 ` Clinton Bunch
2024-04-06 16:48   ` Clinton Bunch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7YcN=LW-qErK+4Xm=YckgwMRtvO1XKYvW+j5Jgho+fHnw@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=cdb_zsh@zentaur.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).