Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Substring/Clojure/substring.clj
Normal file
22
Task/Substring/Clojure/substring.clj
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
(def string "alphabet")
|
||||
(def n 2)
|
||||
(def m 4)
|
||||
(def len (count string))
|
||||
|
||||
;starting from n characters in and of m length;
|
||||
(println
|
||||
(subs string n (+ n m))) ;phab
|
||||
;starting from n characters in, up to the end of the string;
|
||||
(println
|
||||
(subs string n)) ;phabet
|
||||
;whole string minus last character;
|
||||
(println
|
||||
(subs string 0 (dec len))) ;alphabe
|
||||
;starting from a known character within the string and of m length;
|
||||
(let [pos (.indexOf string (int \l))]
|
||||
(println
|
||||
(subs string pos (+ pos m)))) ;lpha
|
||||
;starting from a known substring within the string and of m length.
|
||||
(let [pos (.indexOf string "ph")]
|
||||
(println
|
||||
(subs string pos (+ pos m)))) ;phab
|
||||
Loading…
Add table
Add a link
Reference in a new issue