From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 8375621802 for ; Tue, 26 Mar 2024 14:03:20 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1711458199; b=h6gGiucWF9WNN3RrwGPp7htroMX5rGrF7YZgGZtTgMgIvqBvoyHbxIp+xmdeBXaO1X40v1eD+u wuAxPBs7prguAZgGRmWbZ3VdXJwC1NCuxRsPegUuTAvGNqD2M+6swUmVYHvh4vWaMx5ab4KBc7 pDSqB7om3SfRsko4jAPxkCy5jpZorcHlJ49lBACh5HdyALxH2/bTEheFec2O7JnskfKiGPlx/F dpMTs11KMKK2VlrU+DsNVMDu3qxtWEIp6YtU5GPvdVZIe/viBFVK9xvFnRcoavNpT29A0PXJAs 6n/e0pK+R6p/iLAyW/f21j77fHpBLIEFfYmm/RPJvd37FA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (iris.zentaur.org) smtp.remote-ip=198.58.127.206; dkim=pass header.d=zentaur.org header.s=dkim20200120 header.a=rsa-sha256; dmarc=pass header.from=zentaur.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1711458199; bh=249WsW2StZmpiU+pxDZs87fpbt7lZGXT9i0YJ1VGD1A=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:DKIM-Signature: DKIM-Signature; b=rueP4vGNUTZDylHjd6w4ecgHehFpLXFyvhgeagAtbECRg752W6Lfk16wZIjCwGWc1ghSl5c8iZ LKUtAVV4xIsozpY+NBfsWuJ6S1eenGhLAxrfF1ot0T3uUHbUtoA/FuLpUQG/uD2mimwoFp19Wj ZLBS969b380hGs8icPhZIn+s/LBAKA9557V4O8gGUF23ibdy3S7B8lk3G66EHuyXhznK3dE9+x QBLQHD4vne5aCnCHEdiyCk4eQUd7AFM1JA5pd5J9J/KcQj0mTOM//s1yIdnQlGrWnMiiycep+L CBkP5qaOsovzwk4Bd9Hs0k19VVYD62nQsW+KzHEU3WL+BQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=249WsW2StZmpiU+pxDZs87fpbt7lZGXT9i0YJ1VGD1A=; b=fr63d2iaKfZdLCuOfHc7zot+fG mXsEnzlR64TYzc3DdtCnq/Fdzhvw6zIYgVWiv0NPRStElGsEfXZ/leq5oZXROCKoKsT5p2PllmFkB TJb/GcAlEZSYdX+Kn9kbIKCoEvTYmG8E0yUoXbKlqrDMlf1sPPkkAaZNVs320bhGGavgZjLUkOrKo NBf3vJZW798eYn6TinECuj+2wag+CxoWmWg75QDNmjW6PgjWFhNq/jWzxS7DeVqwra7rpkmBWTF0u Eeu2e6D47GrTG6tx+i7a0QLhkrnLt0DSXPcFrAcwDX6ZMp5HdKUCjV1LQdIpdmZZyDIE2U4JJpYZn qTW4fgFA==; Received: by zero.zsh.org with local id 1rp6SV-000Cp8-SQ; Tue, 26 Mar 2024 13:03:19 +0000 Authentication-Results: zsh.org; iprev=pass (iris.zentaur.org) smtp.remote-ip=198.58.127.206; dkim=pass header.d=zentaur.org header.s=dkim20200120 header.a=rsa-sha256; dmarc=pass header.from=zentaur.org; arc=none Received: from iris.zentaur.org ([198.58.127.206]:36000) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rp6QV-000CRE-0p; Tue, 26 Mar 2024 13:01:16 +0000 Received: from iris.zentaur.org (localhost [127.0.0.1]) by iris.zentaur.org (Postfix) with ESMTP id 4V3qgG0gNHz3wZv for ; Tue, 26 Mar 2024 13:01:14 +0000 (UTC) Authentication-Results: iris.zentaur.org (amavis); dkim=pass (2048-bit key) reason="pass (just generated, assumed good)" header.d=zentaur.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=zentaur.org; h= content-transfer-encoding:content-type:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version :date:message-id; s=dkim20200120; t=1711458073; x=1711461674; bh=249WsW2StZmpiU+pxDZs87fpbt7lZGXT9i0YJ1VGD1A=; b=QyZK2Up0g1Rq sUXL93ahzHcJs8ARt0CTz8aacguB7N1tTMtfMT6dwCiyHiT8bXznooZsot2P3LFH WNs+UisnSINCcdJLsIVaQ+rjZiluEsuOs8Gol92H9/CPZXLAmLJB50xaDQNx3OYY 65vSrY9WQWN6WrNmP5pPq+kabFuDuGLu4FLp6ZhuzftCSj5NsoqgyBgx7JnRNK7Y BsyZvIDLD1ITs7mP2UgIrpAFE8ZOf0uEN5xxDq2KgafLHpp05nJvg5TmfMApTSIQ iUJgiF6e69Lff0zwwR35sVqkGU7I1FoDU05rmh4og+wZRTu0R7sLNCcaS1GOrrJ8 m+ivr7kC4g== X-Virus-Scanned: amavis at iris.zentaur.org Received: from iris.zentaur.org ([127.0.0.1]) by iris.zentaur.org (iris.zentaur.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 0JlR79NqPVaH for ; Tue, 26 Mar 2024 13:01:13 +0000 (UTC) Received: from [IPV6:2605:a601:a57c:ee00::4000] (unknown [IPv6:2605:a601:a57c:ee00::4000]) by iris.zentaur.org (Postfix) with ESMTPSA id 4V3qgF40TSz3wZt for ; Tue, 26 Mar 2024 13:01:13 +0000 (UTC) Message-ID: <7a067deb-7e27-4fae-959d-d17f7e5b4f90@zentaur.org> Date: Tue, 26 Mar 2024 08:01:13 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 0/1] zsh/random module Content-Language: en-US To: zsh-workers@zsh.org References: <57374b5f-77b9-4dee-aaba-5c4bdeb1b281@zentaur.org> From: Clinton Bunch In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Seq: 52827 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On 3/26/2024 07:47, Clinton Bunch wrote: > On 3/24/2024 21:34, Bart Schaefer wrote: >> On Sun, Mar 24, 2024 at 7:11=E2=80=AFAM Clinton Bunch =20 >> wrote: >>> zrand_int takes 0-3 arguments, an exclusive upper bound, a lower boun= d, >>> a flag to make the upper bound inclusive. >> Documentation remarks: >> >> +optional.=C2=A0 If none are specified it is equivilent to >> >> Typo: "equivalent' >> >> +tt(inclusive) is a flag to determine whether the result can ever equa= l >> +tt(upper).=C2=A0 By default it can not. If this argument is set to a=20 >> non-zero value >> +then it can. >> >> Something about the use of "can" in those sentences strikes me as odd. >> =C2=A0=C2=A0 a flag that controls whether the result is ever equal to >> =C2=A0=C2=A0 by default it is not >> =C2=A0=C2=A0 then it may be >> ?? >> >> +possible return values 0-15, in order to use it as an array index=20 >> which goes >> +from 1-16 you need to add one.=C2=A0 Since it can return zero, you do= n't=20 >> want it >> +to return 16. >> >> It took me a few re-readings to figure out that "16" is meant as an >> example result of $#a from the previous two expressions.=C2=A0 The swi= tch >> to addressing the reader as in "you need" / "you don't want" threw me >> off.=C2=A0 Perhaps adding: >> =C2=A0=C2=A0 For example, if $#a is 16, >> and then end sentence and start again: >> =C2=A0=C2=A0 values 0-15.=C2=A0 Thus in order >> I might also change "Since" to "Because". >> > Does this work better: > > tt(inclusive) is a flag that controls whether the result is ever equal = to > tt(upper).=C2=A0 By default it is not. If this argument is set to a=20 > non-zero value > then it may be. > > This is to facilitate a construct like tt($a[zrand_int($#a)+1]) rather > than tt($a[zrand_int+LPAR()$#a-1+RPAR()+1]). > For example, if $#a is 16, you would use tt(zrand_int+LPAR()16RPAR())=20 > which has > 16 possible return values 0-15, in order to use it as an array index=20 > which goes > from 1-16 you need to add one.=C2=A0 Because the function can return ze= ro,=20 > it would > be an array index range error for it to also potentially return 16=20 > ($#a). You > could, however, use the construct tt(zrand_int+LPAR()16,1,1+RPAR())=20 > instead of > adding 1 to achieve the same result, but it is more verbose. > > Most statistics algorithms seem to also expect 0 to tt(upper)-1, so=20 > this was > deemed the most commonly desired case and chosen as the default. > > Also added a statement that the default values of upper and lower are=20 also their limits. tt(upper) is the upper bound on the resultant number and defaults to 4,294,967,295. tt(lower) is the lower bound and defaults to 0. The defaults of these two arguments are also the maximum and minimum to=20 which either can be set.