Strings are sequences of characters. count and subs count characters, not bytes, so a character such as é is one unit. Character literals look like \a. first returns the first character.
count
subs
é
\a
first
(require '[clojure.string :as string]) (def greeting "héllo") (println (count greeting)) (println (subs greeting 1 4)) (println (first greeting)) (println (string/upper-case greeting)) (println (string/reverse greeting))
subs takes a start index and an exclusive end index.
$ glj strings-and-characters.glj 5 éll h HÉLLO olléh
Next example: Namespaces.
A hands-on tour in the style of Go by Example. Glojure is a Clojure interpreter hosted on Go.