Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

15
LINES

< > BotCompany Repo | #1004708 // 2-Grams Predictor [Lua]

Lua code

-- a, b is our "buffer" for last 2 chars
pairs = {}
function p(m, s)
  if s ~= nil then
    -- fill buffer
    for i = 1, s:len() do
      a = b
      b = s:sub(i)
      if a ~= nil then
        pairs[a] = b
      end
    end
  end
  return pairs[b]
end

Author comment

m = max chars to return
s = fed "real" input

test run  test run with input  download  show line numbers   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

Comments [hide]

ID Author/Program Comment Date
1296 stefan Scores 24.5% on #1004698 2016-08-27 16:03:57

add comment

Snippet ID: #1004708
Snippet name: 2-Grams Predictor [Lua]
Eternal ID of this version: #1004708/1
Text MD5: 976a4a3f7326762539f30de71b59d06f
Author: stefan
Category: javax / a.i.
Type: Lua code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-08-27 15:52:01
Source code size: 267 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 836 / 174
Referenced in: [show references]