From 921b7f91c1726b1e64a9477797b2464f73b07be0 Mon Sep 17 00:00:00 2001 From: SteveU Date: Sun, 14 Aug 2022 16:43:31 -0700 Subject: [fifty.bqn] Update to fifty.bqn to use scans Update #9 and #10 to use scans rather than nested arrays. Scans are faster, and I feel like provide a better working example for new BQN programmers. However, this does change the math a bit as scans in BQN are left to right whereas APL's are right to left. --- examples/fifty.bqn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/fifty.bqn b/examples/fifty.bqn index fb336dfe..77f83a33 100644 --- a/examples/fifty.bqn +++ b/examples/fifty.bqn @@ -59,11 +59,11 @@ PascalsTriangle ← {>𝕩↑¨0(∾+∾˜)⍟(↕𝕩)⥊1} ! 1‿1‿2‿3‿5‿8‿13‿21‿34‿55 ≡ { 𝕩 ↑ +´¨ (+⌜˜↕𝕩) ⊔○⥊ PascalsTriangle 𝕩 } 10 # 9 -GoldenRatio ← +⟜÷´¨∘(1↓↑) ⥊⟜1 +GoldenRatio ← ÷⊸+`⥊⟜1 ! 1e¯5 ∧´∘> | (GoldenRatio 16) - 1‿2‿1.5‿1.66667‿1.6‿1.625‿1.61538‿1.61905‿1.61765‿1.61818‿1.61798‿1.61806‿1.61803‿1.61804‿1.61803‿1.61803 # 10 -NewtonsMethod ← (2 ÷˜ ⊢ + ÷)´¨∘(1↓↑) ⥊ +NewtonsMethod ← (2 ÷˜ ⊣ + ÷˜)` ⥊ ! 1e¯5 ∧´∘> | (7 NewtonsMethod 2) - 2‿1.5‿1.41667‿1.41422‿1.41421‿1.41421‿1.41421 # 11 -- cgit v1.2.3