diff options
Diffstat (limited to 'reading.lua')
-rw-r--r-- | reading.lua | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/reading.lua b/reading.lua index 2b74446..6c910e2 100644 --- a/reading.lua +++ b/reading.lua @@ -1,3 +1,8 @@ +local function trigram_to_value (a, b, c) + return a * 25 + b * 5 + c +end + + local function next_trigram (message, index) index = (index or 0) + 1 local offset = (index - 1) * 3 @@ -15,23 +20,33 @@ local function next_value (message, index) if not index then return nil end - return index, a * 25 + b * 5 + c + return index, trigram_to_value(a, b, c) end local reading = { + trigram_to_value = trigram_to_value, next_trigram = next_trigram, next_value = next_value, } function reading.trigrams (message, start) - return next_trigram, message, start + return next_trigram, message, start or 0 end function reading.values (message, start) - return next_value, message, start + return next_value, message, start or 0 +end + + +function reading.tvalues (message) + local values = {} + for _, value in reading.values(message) do + table.insert(values, value) + end + return values end |