From 3212d37f8e7c2b2aba706ab5e5064fae84526956 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Fri, 30 May 2025 16:41:55 +0100 Subject: add qw.lua --- pos.lua | 1 + qw.lua | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 qw.lua diff --git a/pos.lua b/pos.lua index 149783e..a3343ee 100644 --- a/pos.lua +++ b/pos.lua @@ -26,6 +26,7 @@ function Pos.__mul(a,b) else error("can only multiply Pos by scalar") end + end function Pos.__div(a,b) assert(type(b) == "number","can only divide Pos by scalar") diff --git a/qw.lua b/qw.lua new file mode 100644 index 0000000..3b27816 --- /dev/null +++ b/qw.lua @@ -0,0 +1,17 @@ +-- qw"aaa bbb ccc" --> { "aaa", "bbb", "ccc" } +local function qw(str) + local out = {} + for x in str:gmatch"%S+" do + table.insert(out, x) + end + return out +end +-- qw.s"aaa bbb ccc" --> { aaa=true, bbb=true, ccc=true } +local function qws(str) + local out = {} + for x in str:gmatch"%S+" do + out[x] = true + end + return out +end +return setmetatable({qw=qw,s=qws},{__call=function(_,...) return qw(...) end}) -- cgit v1.2.3