diff options
| author | SteveU <steveulin@gmail.com> | 2022-08-14 16:43:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-14 16:43:31 -0700 |
| commit | 921b7f91c1726b1e64a9477797b2464f73b07be0 (patch) | |
| tree | 1f97839912f4c4442990a75a4d851cbcdd0b9a06 | |
| parent | 8afd6d6d22e3b123423a95eae1389c3fa942a066 (diff) | |
[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.
| -rw-r--r-- | examples/fifty.bqn | 4 |
1 files 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 |
