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 9D466213C0 for ; Tue, 26 Mar 2024 13:47:51 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1711457271; b=M5raa9eBm1UTGJxrHculqG80uDBZ7+LMQve4vjiD0KXmn3Nj6sYUPQZyXuP7JF2BbYoCnlBbuL vBXeWJFDVuwR1GNnsPetrASy/2fxQfOrHWk1dzUn05NRLuo5rvNPDuDKcF4d/aQM0RlatCPUoh 3KtHK+bJpMjimEi+QaKflTi+VXoyiLlBGbIcAUwcw1tY4xyDoFTYEqKMNp2G/K7BOl7KM/ljFC qbbd1iApTXzfwocZLTJiHHCGyTJNZgd3OTA8u8ONT60pFnzwYtNixhXqyqgb07WUAbO0NOO4IG Wb2OoRWYJfNc+j+AUB9zE8SyOIA3JpUmEm0XXznSXf/0RQ==; 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=1711457271; bh=K9N5y7QD/Fxkz+Xt9faG62aHemo56/fjfI/TCaQ1M8Y=; 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=n7p6hfJFURp9VeTA+v2/sxWePSsAH2wVsHKcv9oIsUYaJPduU5wzgULwVyxB8EOgih2mKZC4t3 6fgCXRUZLUptOv+6VMa5HDG9cUu83Wg6UrvLs+0HQZZSsoZk0V1Otpl0tLK+GdhadAjuJaDNjG tcfPWAHb/tdFPEVLaZ2eXTM6+D/8KaZnkMt/FBNiLXjwN9LGne56iedN0YS/GXcrJHRttZR9/c 3USaMzAX436KKBLldwTtFNV1d6nt876244gxnZ2jo5SBwFIJLIujZUNKxNBaft2HwjJf3VTrtU jhV9oNVWTsxhJjkZ9sXA4XtMDmtdUC2IQZV/69OULKYPDw==; 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=CbQemCU67ZfDuIKrWDs3Ck5Jz+qIPoy69R3Az4V3zAE=; b=pLWj2Xucx52CVq2Gnt1DhjVj7H KSJl1VO/IXFARp6Z7LXTs2orNUBP/EQOoHrxYYNtmTQJ8/w3wCeCxbP6ky604BXvYMHUSJTVxDziC dLvqgVVCMvBc7oMDn2SULaBejnJ01xMtGg+X7HRbhaP3OtJ7jEdz01f26uBBbCmdbo6EflCmoz3/B fCENCYLp4hDv58H0seZhtm3qLkt/mNBKYCWWnQOQl94hoDVJVFnXwwXIV0FIMupSj72Hn4DU4+E4T xb2dkCuvQcOZiM26szbIeV23TTGg/IR3MBeNZyU8NnIjenW+JZUCDdvGbZs/FK6HGtANPsMcUi8Tv qKtELMcg==; Received: by zero.zsh.org with local id 1rp6DW-000Bnv-3X; Tue, 26 Mar 2024 12:47:50 +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]:33092) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rp6DC-000BW8-0s; Tue, 26 Mar 2024 12:47:31 +0000 Received: from iris.zentaur.org (localhost [127.0.0.1]) by iris.zentaur.org (Postfix) with ESMTP id 4V3qMM6VW3z3wZv for ; Tue, 26 Mar 2024 12:47:27 +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=1711457247; x=1711460848; bh=K9N5y7QD/Fxkz+Xt9faG62aHemo56/fjfI/TCaQ1M8Y=; b=pOqsenmnZ+2M DbrIA+1C/Kbj8aIyCq2cIyVZgBrqrQ4L0kSpxf9XM/nUvvmFIclc2I99602YDQLg 2/1ZAheuAfnkN6C6/lo6Yvj59Tt8R7NeLwZMRQuDH9n2BBZDyGF+jKwQUzjSM3Pg D84mvrVesBTrhl3NwAAHO4FJnuTJ7YEzfPX9Omd/BdCsThUggUecPd4lny0EZA55 i3bc/DUCVLrhQ6+/F1AVxWt0ptJJe0oifjC0gJsREYW3E+Dz+NcF4vDHyHRyfmFR 80ouBaJ3EiTHB88J1Rainq+HmnLLIsddAquFOWYURS1Ra/1XjNTfq2J2o8c4Eew8 hpvCH3EGlA== 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 IyeRleaNjduK for ; Tue, 26 Mar 2024 12:47:27 +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 4V3qMM1fglz3wZt for ; Tue, 26 Mar 2024 12:47:27 +0000 (UTC) Message-ID: Date: Tue, 26 Mar 2024 07:47:27 -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: 52826 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/24/2024 21:34, Bart Schaefer wrote: > On Sun, Mar 24, 2024 at 7:11=E2=80=AFAM Clinton Bunch wrote: >> zrand_int takes 0-3 arguments, an exclusive upper bound, a lower bound= , >> a flag to make the upper bound inclusive. > Documentation remarks: > > +optional. If none are specified it is equivilent to > > Typo: "equivalent' > > +tt(inclusive) is a flag to determine whether the result can ever equal > +tt(upper). By default it can not. If this argument is set to a non-ze= ro value > +then it can. > > Something about the use of "can" in those sentences strikes me as odd. > a flag that controls whether the result is ever equal to > by default it is not > then it may be > ?? > > +possible return values 0-15, in order to use it as an array index whic= h goes > +from 1-16 you need to add one. Since it can return zero, you don't wa= nt 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. The switch > to addressing the reader as in "you need" / "you don't want" threw me > off. Perhaps adding: > For example, if $#a is 16, > and then end sentence and start again: > values 0-15. 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 non-z= ero=20 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 zero= , it=20 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 this = was deemed the most commonly desired case and chosen as the default.