aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2021-01-19 13:43:39 +0100
committerAbigail <abigail@abigail.be>2021-01-19 13:43:39 +0100
commit6a8e97190d55b1e0f94318e4e0316e50de7415c0 (patch)
treea26573730f479137c5fae1a78fa2753c0cdd3c06
parentb3fd5101407177b4d9a8e2d41b3e063269cee6ba (diff)
downloadperlweeklychallenge-club-6a8e97190d55b1e0f94318e4e0316e50de7415c0.tar.gz
perlweeklychallenge-club-6a8e97190d55b1e0f94318e4e0316e50de7415c0.tar.bz2
perlweeklychallenge-club-6a8e97190d55b1e0f94318e4e0316e50de7415c0.zip
lua solution for week 96, part 1
-rw-r--r--challenge-096/abigail/README.md1
-rw-r--r--challenge-096/abigail/lua/ch-1.lua14
2 files changed, 15 insertions, 0 deletions
diff --git a/challenge-096/abigail/README.md b/challenge-096/abigail/README.md
index b0b0617ad2..31f4073f0d 100644
--- a/challenge-096/abigail/README.md
+++ b/challenge-096/abigail/README.md
@@ -22,6 +22,7 @@ Output: "family same the of part are Raku and Perl"
### Solutions
* [AWK](awk/ch-1.awk)
* [C](c/ch-1.c)
+* [lua](lua/ch-1.lua)
* [Node.js](node/ch-1.js)
* [Perl](perl/ch-1.pl)
* [Python](python/ch-1.py)
diff --git a/challenge-096/abigail/lua/ch-1.lua b/challenge-096/abigail/lua/ch-1.lua
new file mode 100644
index 0000000000..68d1c5eb86
--- /dev/null
+++ b/challenge-096/abigail/lua/ch-1.lua
@@ -0,0 +1,14 @@
+for line in io . lines () do
+ --
+ -- Extract words and put them into an array, in reverse.
+ --
+ words = {}
+ for str in string . gmatch (line, "[^ ]+") do
+ table . insert (words, 1, str)
+ end
+
+ --
+ -- Print the words
+ --
+ io . write (table . concat (words, " "), "\n")
+end