summaryrefslogtreecommitdiff
path: root/qw.lua
diff options
context:
space:
mode:
Diffstat (limited to 'qw.lua')
-rw-r--r--qw.lua17
1 files changed, 17 insertions, 0 deletions
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})