aboutsummaryrefslogtreecommitdiff
path: root/challenge-331/hvukman/lua/331_p1.lua
diff options
context:
space:
mode:
authorHVukman <peterslopp@googlemail.com>2025-07-27 19:10:26 +0200
committerGitHub <noreply@github.com>2025-07-27 19:10:26 +0200
commit1b5873f2797e27cf00ca842b39f5c3762facb50c (patch)
tree1c3c0c9305112c44d3c9c993612cf0b49cece223 /challenge-331/hvukman/lua/331_p1.lua
parent1ff2c9796a511d63231d3757acb27e4046a91fb2 (diff)
downloadperlweeklychallenge-club-1b5873f2797e27cf00ca842b39f5c3762facb50c.tar.gz
perlweeklychallenge-club-1b5873f2797e27cf00ca842b39f5c3762facb50c.tar.bz2
perlweeklychallenge-club-1b5873f2797e27cf00ca842b39f5c3762facb50c.zip
Create 331_p1.lua
Diffstat (limited to 'challenge-331/hvukman/lua/331_p1.lua')
-rw-r--r--challenge-331/hvukman/lua/331_p1.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-331/hvukman/lua/331_p1.lua b/challenge-331/hvukman/lua/331_p1.lua
new file mode 100644
index 0000000000..bf882dab1d
--- /dev/null
+++ b/challenge-331/hvukman/lua/331_p1.lua
@@ -0,0 +1,20 @@
+-- http://lua-users.org/wiki/StringTrim
+function Trim(s)
+ return s:match'^()%s*$' and '' or s:match'^%s*(.*%S)'
+end
+
+function Last_length (X)
+ local words = {}
+
+ for word in Trim(X):gmatch("%w+") do
+ table.insert(words, word)
+ end
+
+ local last_word = words[#words]
+ print(#last_word)
+
+end
+
+Last_length("The Weekly Challenge")
+Last_length(" Hello World ")
+Last_length("Let's begin the fun")