aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-04-23 17:20:48 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-04-23 17:20:48 -0400
commitb0996fd545a32e017a2aa2e94eed79eea15091b1 (patch)
tree17b2b151163f1c543a3a7f9f8fb9dc340582e8bd /src
parentbec36db405779540487b9ed17c89edd9b92782c6 (diff)
Special case for repeat by natural number
Diffstat (limited to 'src')
-rw-r--r--src/r.bqn17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/r.bqn b/src/r.bqn
index c23e5f48..075efa3b 100644
--- a/src/r.bqn
+++ b/src/r.bqn
@@ -696,14 +696,17 @@ ProgressiveIndexOf ← 0 Fill {
⁼ ← {Inverse 𝕗}
_repeat_←{
+ F←𝔽 ⋄ b←𝕨{𝕏⊣}˙⊘{𝕨˙{𝔽𝕏⊣}}0
n←𝕨𝔾𝕩
- l←u←0
- {"⍟: Repetition numbers in 𝕨 must be integers"!Int𝕩⋄l↩l⌊𝕩⋄u↩u⌈𝕩}⚇0 n
- b←𝕨{𝕏⊣}˙⊘{𝕨˙{𝔽𝕏⊣}}0
- i←⟨𝕩⟩⋄P←B⊸{𝕎`i∾↕𝕩}
- pos←𝕗 P u
- neg←𝕗 0⊸<◶⟨i,Inverse⊸P⟩ -l
- (|⊑<⟜0⊑pos‿neg˙)⚇0 n
+ Multi←{
+ l←u←0
+ {"⍟: Repetition numbers in 𝕨𝔾𝕩 must be integers"!Int𝕩⋄l↩l⌊𝕩⋄u↩u⌈𝕩}⚇0 n
+ i←⟨𝕩⟩⋄P←B⊸{𝕎`i∾↕𝕩}
+ pos←f P u
+ neg←f 0⊸<◶⟨i,Inverse⊸P⟩ -l
+ (|⊑<⟜0⊑pos‿neg˙)⚇0 n
+ }
+ (Nat n)◶Multi‿{𝕩(B f)∘⊢´↕n} 𝕩
}
⍟ ↩ _repeat_