diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-03-06 16:38:49 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-03-06 16:38:49 -0800 |
commit | 6a3098d0e93cff07045f27c231cf30114bb013a1 (patch) | |
tree | ed98c3ac12f09ca948917cad6a19a2b05b8c8371 /template.tlv | |
parent | 5758f6c082af702e8e2c6c6e6d88f987b3deedee (diff) | |
download | teliva-6a3098d0e93cff07045f27c231cf30114bb013a1.tar.gz |
use method syntax where possible
Perhaps this is a bad idea. It feels arbitrary, what methods Lua happens to include in string and table objects without having to go through the respective modules.
Diffstat (limited to 'template.tlv')
-rw-r--r-- | template.tlv | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/template.tlv b/template.tlv index aa78955..ba92fbf 100644 --- a/template.tlv +++ b/template.tlv @@ -23,7 +23,7 @@ >-- index characters using [] >getmetatable('').__index = function(str,i) > if type(i) == 'number' then - > return string.sub(str,i,i) + > return str:sub(i,i) > else > return string[i] > end @@ -32,11 +32,11 @@ >-- ranges using (), selected bytes using {} >getmetatable('').__call = function(str,i,j) > if type(i)~='table' then - > return string.sub(str,i,j) + > return str:sub(i,j) > else > local t={} > for k,v in ipairs(i) do - > t[k]=string.sub(str,v,v) + > t[k]=str:sub(v,v) > end > return table.concat(t) > end @@ -201,7 +201,7 @@ count_letters: >function count_letters(s) > local result = {} - > for i=1,string.len(s) do + > for i=1,s:len() do > local c = s[i] > if result[c] == nil then > result[c] = 1 @@ -257,7 +257,7 @@ > end > end > h.addstr = function(self, s) - > for i=1,string.len(s) do + > for i=1,s:len() do > self:addch(s[i]) > end > end @@ -277,7 +277,7 @@ kbd: >function kbd(keys) > local result = {} - > for i=1,string.len(keys) do + > for i=1,keys:len() do > table.insert(result, keys[i]) > end > return result @@ -299,7 +299,7 @@ check_screen: >function check_screen(window, contents, message) > local x, y = 1, 1 - > for i=1,string.len(contents) do + > for i=1,contents:len() do > check_eq(contents[i], window.scr[y][x], message..'/'..y..','..x) > x = x+1 > if x > window.scr.w then |