diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-12-08 00:40:22 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-12-08 00:40:22 -0800 |
commit | 71ce944e816b7e3de4b1ea6ae67f595d09960b4d (patch) | |
tree | 1f82fc08117fddb3352776f49ecc8e5341a162f6 | |
parent | 74fd78c5b77311fe9d285dd0128c5d0d6c56794a (diff) | |
download | teliva-71ce944e816b7e3de4b1ea6ae67f595d09960b4d.tar.gz |
couple more primitives after Advent day 8
-rw-r--r-- | advent.tlv | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/advent.tlv b/advent.tlv index a801b11..61cf3d9 100644 --- a/advent.tlv +++ b/advent.tlv @@ -150,6 +150,28 @@ end { __teliva_timestamp = [==[ original]==], + find_index = [==[ +function find_index(arr, x) + for n, y in q(arr) do + if x == y then + return n + end + end +end +]==], + }, + { + __teliva_timestamp = [==[ +original]==], + trim = [==[ +function trim(s) + return s:gsub('^%s*', ''):gsub('%s*$', '') +end +]==], + }, + { + __teliva_timestamp = [==[ +original]==], split = [==[ function split(s, d) result = {} |