!752 static int sep = 0; p { load("sep"); } static S lua = [[ -- build a word tree (character occurrence tree) and walk it pairs = {} wordTree = {} wordTreeP = wordTree isSep = {} seps = "SEPS" for i = 1, seps:len() do isSep[seps:sub(i, i)] = true end function p(m, s) if s ~= nil then for i = 1, s:len() do local c = s:sub(i, i) if isSep[c] then wordTreeP = wordTree else local n = wordTreeP[c] if n == nil then n = {} wordTreeP[c] = n end wordTreeP = n end end end local c, n = next(wordTreeP) return c end ]]; static S strategy(S text) { if (sep >= 0x100) ret "done"; sep++; save("sep"); S seps = str((char) sep); print("Trying sep " + quote(seps)); ret lua.replace([["SEPS"]], luaQuote(seps)); } static void reset() { sep = 0; save("sep"); }