aboutsummaryrefslogtreecommitdiff
path: root/challenge-240/deadmarshal/lua/ch-1.lua
diff options
context:
space:
mode:
author冯昶 <fengchang@novel-supertv.com>2023-10-31 11:13:53 +0800
committer冯昶 <fengchang@novel-supertv.com>2023-10-31 11:13:53 +0800
commit50b486fa26bc3ad30ed80a83f269f8dc93fd8bcd (patch)
tree3b43cb77c4d042b62b31fd95e04caeaddc2f3bba /challenge-240/deadmarshal/lua/ch-1.lua
parent7fe999f4ae6a14b7f3497f06eaa936c6fcbe6436 (diff)
parent71ad4139989a590a4a64b128ae3de74f7c19bad8 (diff)
downloadperlweeklychallenge-club-50b486fa26bc3ad30ed80a83f269f8dc93fd8bcd.tar.gz
perlweeklychallenge-club-50b486fa26bc3ad30ed80a83f269f8dc93fd8bcd.tar.bz2
perlweeklychallenge-club-50b486fa26bc3ad30ed80a83f269f8dc93fd8bcd.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-240/deadmarshal/lua/ch-1.lua')
-rw-r--r--challenge-240/deadmarshal/lua/ch-1.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/challenge-240/deadmarshal/lua/ch-1.lua b/challenge-240/deadmarshal/lua/ch-1.lua
new file mode 100644
index 0000000000..ee4ca54726
--- /dev/null
+++ b/challenge-240/deadmarshal/lua/ch-1.lua
@@ -0,0 +1,14 @@
+#!/usr/bin/env lua
+
+local function acronym(t,check)
+ assert(type(t) == 'table' and type(check) == 'string',
+ 't,check must be a table and a string respectively!')
+ local str_table = {}
+ for i=1,#t do table.insert(str_table,t[i]:sub(1,1):lower()) end
+ return table.concat(str_table) == check
+end
+
+print(acronym({'Perl', 'Python', 'Pascal'},'ppp'))
+print(acronym({'Perl', 'Raku'},'rp'))
+print(acronym({'Oracle', 'Awk', 'C'},'oac'))
+