aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKang-min Liu <gugod@gugod.org>2021-01-19 23:19:44 +0900
committerKang-min Liu <gugod@gugod.org>2021-01-19 23:19:44 +0900
commit36b1f754eb8d9d230e6c1577dc9063a46f914cd0 (patch)
treeb8b62163dd636316ea94433511330e6c2718f313
parent8ea7856804c9fdf27fd8e4a0ab576cf5255df9a1 (diff)
downloadperlweeklychallenge-club-36b1f754eb8d9d230e6c1577dc9063a46f914cd0.tar.gz
perlweeklychallenge-club-36b1f754eb8d9d230e6c1577dc9063a46f914cd0.tar.bz2
perlweeklychallenge-club-36b1f754eb8d9d230e6c1577dc9063a46f914cd0.zip
a solution to pwc 096.1 in janet
-rw-r--r--challenge-096/gugod/janet/ch-1.janet15
1 files changed, 15 insertions, 0 deletions
diff --git a/challenge-096/gugod/janet/ch-1.janet b/challenge-096/gugod/janet/ch-1.janet
new file mode 100644
index 0000000000..f3d0e18544
--- /dev/null
+++ b/challenge-096/gugod/janet/ch-1.janet
@@ -0,0 +1,15 @@
+
+(defn reverse-words
+ "Reverse the string word by word"
+ [S]
+ (string/join (reverse (filter (fn [x] (not (= x "")))
+ (string/split " " S)))
+ " "))
+
+# main
+(loop [x :in @["The Weekly Challenge"
+ " Perl and Raku are part of the same family "
+ "join reverse split $S"]]
+ (print (string
+ "Input: " x "\n"
+ "Output: " (reverse-words x))))