aboutsummaryrefslogtreecommitdiffhomepage
path: root/std/Math.bruijn
diff options
context:
space:
mode:
authorMarvin Borner2024-02-29 23:28:51 +0100
committerMarvin Borner2024-02-29 23:28:51 +0100
commitfe0de617cddd2dee11758788c5dc9b7a1c8f330a (patch)
tree26354608f8b8d1573e6fa593ee92460aa0616884 /std/Math.bruijn
parentf3eefd551566cc07232a8c15d8162738bf1f8fec (diff)
great changes
you gotta believe me, they're great. they're the best
Diffstat (limited to 'std/Math.bruijn')
-rw-r--r--std/Math.bruijn16
1 files changed, 13 insertions, 3 deletions
diff --git a/std/Math.bruijn b/std/Math.bruijn
index cfea07c..ae67136 100644
--- a/std/Math.bruijn
+++ b/std/Math.bruijn
@@ -77,9 +77,6 @@ pow* z [[[rec]]] ⧗ Number → Number → Number
³‣ [0 ⋅ 0 ⋅ 0]
case-end (+1)
-# prime number sequence
-primes nub ((…≠?… (+1)) ∘∘ gcd) (iterate ++‣ (+2)) ⧗ (List Number)
-
# factorial function
fac [∏ (+1) → 0 | i] ⧗ Number → Number
@@ -192,6 +189,19 @@ log* [z [[rec]] --0] ⧗ Number → Number
# TODO: something is wrong in here
pascal iterate [zip-with …+… ({}(+0) ++ 0) (0 ; (+0))] ({}(+1))
+# characteristic prime sequence by Tromp
+characteristic-primes ki : (ki : (sieve s0)) ⧗ (List Bool)
+ sieve y [[k : ([(2 0) (y' 0)] (ssucc 0))]]
+ y' [[0 0] [1 (0 0)]]
+ ssucc [[[[1 : (0 (3 2))]]]]
+ s0 [[[ki : (0 2)]]]
+
+# prime number sequence
+primes map fst (filter snd (zip (iterate ++‣ (+0)) characteristic-primes)) ⧗ (List Number)
+
+# slower but cooler prime number sequence
+primes* nub ((…≠?… (+1)) ∘∘ gcd) (iterate ++‣ (+2)) ⧗ (List Number)
+
# π as a list of decimal digits
# translation of unbounded spigot algorithm by Jeremy Gibbons
# TODO: faster!