From 87fd60f6d3f574155214fea44147c7f0a8744e71 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 31 May 2021 14:32:18 -0400 Subject: Allow Rand to take a shape left argument --- test/fuzz.bqn | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/fuzz.bqn b/test/fuzz.bqn index 1bc10213..ee116a2f 100644 --- a/test/fuzz.bqn +++ b/test/fuzz.bqn @@ -7,8 +7,10 @@ _makeRand ← {st←𝕗 {𝕤⋄ d ⌊∘÷˜ st ↩ m|2531011+214013×st } } RandGen ← 1234 _makeRand -Rand ← { 𝕩 | 0 rr⊸×⊸+˜´ RandGen¨↕⌈rr⋆⁼𝕩 }∘(1⊸⌈)⚇0 +RandSh ← ⊢ ⥊ ·RandGen¨ (↕×´) +Rand ← { 𝕩⌈↩1 ⋄ 𝕨 ⊢⊘⥊ 𝕩 | 0 rr⊸×⊸+˜´ (𝕨RandGen⊘(RandSh∘⊣)⊢)¨↕⌈rr⋆⁼𝕩 } _randChoose ← { Rand∘(≠𝕗)◶𝕗 } +_randUnbounded ← { 𝕊⊸+⍟(1=-)⟜Rand 𝕗 } # Prime factorization ⟨Factor⟩ ← { @@ -30,7 +32,7 @@ Sigmoid ← (40≤|)◶⟨1(-÷+)˜⋆,×⟩ -⟜1 ⌊ Rand∘(1⌈⌈)⌾((2⋆3+⊢)⁼) + ¯7+Rand∘15 # Near power of two ⟩_randChoose - RandRank ← { 𝕊⊸+⍟(1=-)⟜Rand 4 } + RandRank ← 4 _randUnbounded Augment ← { d ← 1+⌊𝕨÷1⌈×´𝕩 # Maximum bound that can be added, plus 1 @@ -39,7 +41,7 @@ Sigmoid ← (40≤|)◶⟨1(-÷+)˜⋆,×⟩ } Combine ← ⟨ Rand∘≠⊸⌽ (2+Rand∘≠)⊸{×´¨𝕨↑(𝕨|↕∘≠)⊸⊔𝕩}∘⊢ # Random number of groups - ×´¨ (⊐·Rand⥊˜∘≠)⊸⊔∘⊢ # Distribute randomly + ×´¨ (⊐·Rand¨⥊˜∘≠)⊸⊔∘⊢ # Distribute randomly ⟩_randChoose RandShape ⇐ ⊢ Augment ⟨ ⊢ (⊢ ⌊∘× ⊢ ≠⊸√ (Sigmoid⊸÷1⌈×´⊸÷˜)) · Rand¨ (RandRank⌈√