An alternative derivation of Shannon entropy
iczelia.net4 pointsby purplesyringa0 comments
-while b"]" + b"=" * level + b"]" in obj:
+# Somewhat surprisingly, Lua forbids even opening brackets inside brackets.
+while b"[" + b"=" * level + b"[" in obj or b"]" + b"=" * level + b"]" in obj:
...but I think I've figured out the problem. It seems like Lua 5.1 specifically forbids level-0 opening brackets within level-0 strings: > print [[ a [[b c ]]
stdin:1: nesting of [[...]] is deprecated near '['
...and Cobalt implements this check for compatibility. So that's another edge case to handle, I guess. if (j != next_j[i][j]) {
j = next_j[i][j];
asm volatile("" : "+r"(j));
}
being (de)optimized to unsigned char value = next_j[i][j];
_Bool flag = j != value;
j = value;
if (flag) {
asm volatile("" : "+r"(j));
}
which in turn could be compiled to `mov reg, [mem]; cmp reg, reg; mov reg, reg; je`, whereas if (j != next_j[i][j]) {
asm volatile("" : "+r"(j));
j = next_j[i][j];
}
doesn't permit such an optimization because it forces a conditional load, which you can't avoid putting behind a branch. a = 98a67ee86f8cf
b = da19d2c9dfe71
(a >> 20) * (b >> 20) = 820d2e04637bf428
(a >> 8) * (b >> 8) % 2**64 = 0547f8cdb2100210
->
(a >> 8) * (b >> 8) = 820d2e0547f8cdb2100210
(a >> 8) * (b >> 8) = 820d2e0547f8cdb2100210
(a * b) % 2**64 = 080978075f64355f
->
a * b = 820d2e0548080978075f64355f
And my attempt at implementation: https://play.rust-lang.org/?version=stable&mode=release&edit...