Cycle detection: Difference between revisions
Content added Content deleted
(added BQN implementation) |
(→{{header|BQN}}: Combine ⍟≠⟜F instances and avoid an unnecessary iteration if x0=F x0) |
||
Line 380: | Line 380: | ||
<lang BQN>_Brent← {F _𝕣 x0: |
<lang BQN>_Brent← {F _𝕣 x0: |
||
p←l←1 |
p←l←1 |
||
{p=l? |
(I ← {p=l? |
||
l↩1 ⋄ p×↩2 ⋄ |
l↩1 ⋄ p×↩2 ⋄ 𝕩I𝕩 ; |
||
l+↩1 ⋄ |
l+↩1 ⋄ 𝕨I𝕩 |
||
} |
}⍟≠⟜F) x0 |
||
m←0 |
m←0 |
||
{m+↩1 ⋄ 𝕨𝕊⍟≠○F𝕩}⟜(F⍟l) x0 |
{m+↩1 ⋄ 𝕨𝕊⍟≠○F𝕩}⟜(F⍟l) x0 |