aboutsummaryrefslogtreecommitdiffstats
path: root/research/experiments/040-against-c/words.aup
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-10-05 13:24:59 +0100
committereunhhu <[email protected]>2026-10-05 13:24:59 +0100
commit6b4580607efa698abdc07718f00c6cbdb425c210 (patch)
tree0cad9cddfd332140ecce47d17e439573f32ea11e /research/experiments/040-against-c/words.aup
parent5a3466e8ff4d8f3c4271719b90858b7d08697dcd (diff)
downloadpure-6b4580607efa698abdc07718f00c6cbdb425c210.tar.gz
pure-6b4580607efa698abdc07718f00c6cbdb425c210.zip
Research 124's suite: seven kinds of work in one event each (roots, knapsack, sort, join, words, matmul, BFS), each against the C one would write, in one process with the same inputs and answers; PURE_AHEAD=0 to measure the code without reading ahead
Diffstat (limited to 'research/experiments/040-against-c/words.aup')
-rw-r--r--research/experiments/040-against-c/words.aup33
1 files changed, 33 insertions, 0 deletions
diff --git a/research/experiments/040-against-c/words.aup b/research/experiments/040-against-c/words.aup
new file mode 100644
index 0000000..af24130
--- /dev/null
+++ b/research/experiments/040-against-c/words.aup
@@ -0,0 +1,33 @@
+# Text (research 124's suite): n words "w0" .. "w{vocabulary - 1}", each
+# drawn by MINSTD from seed 1, counted in a list kept by the word: how many
+# distinct, and the most any one is seen. A let holds no text (aup), so the
+# word is written where it is used.
+record Count {
+ word: text
+ n = 0
+}
+state distinct = 0
+state most = 0
+input go = message {
+ n: u32
+ vocabulary: u32
+}
+on go {
+ let counts: list of Count by word
+ let x = 1
+ for i in 0 .. go.n {
+ x = x * 48271 - floor(x * 48271 / 2147483647) * 2147483647
+ let n = x - floor(x / go.vocabulary) * go.vocabulary
+ if counts.has("w{n}") {
+ counts["w{n}"].n = counts["w{n}"].n + 1
+ } else {
+ counts.add(Count { word: "w{n}", n: 1 })
+ }
+ }
+ distinct = counts.count
+ let m = 0
+ for c in counts {
+ m = max(m, c.n)
+ }
+ most = m
+}