Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
26
Task/Odd-word-problem/Clojure/odd-word-problem-1.clj
Normal file
26
Task/Odd-word-problem/Clojure/odd-word-problem-1.clj
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
(defn next-char []
|
||||
(char (.read *in*)))
|
||||
|
||||
(defn forward []
|
||||
(let [ch (next-char)]
|
||||
(print ch)
|
||||
(if (Character/isLetter ch)
|
||||
(forward)
|
||||
(not= ch \.))))
|
||||
|
||||
(defn backward []
|
||||
(let [ch (next-char)]
|
||||
(if (Character/isLetter ch)
|
||||
(let [result (backward)]
|
||||
(print ch)
|
||||
result)
|
||||
(fn [] (print ch) (not= ch \.)))) )
|
||||
|
||||
(defn odd-word [s]
|
||||
(with-in-str s
|
||||
(loop [forward? true]
|
||||
(when (if forward?
|
||||
(forward)
|
||||
((backward)))
|
||||
(recur (not forward?)))) )
|
||||
(println))
|
||||
6
Task/Odd-word-problem/Clojure/odd-word-problem-2.clj
Normal file
6
Task/Odd-word-problem/Clojure/odd-word-problem-2.clj
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
user=> (odd-word "what,is,the;meaning,of:life.")
|
||||
what,si,the;gninaem,of:efil.
|
||||
nil
|
||||
user=> (odd-word "we,are;not,in,kansas;any,more.")
|
||||
we,era;not,ni,kansas;yna,more.
|
||||
nil
|
||||
Loading…
Add table
Add a link
Reference in a new issue