Clojure - Strings count



To find the number of characters in a string, you can use the count function.

Syntax

Following is the syntax.

(count stringvariable)

Parameters − ‘Stringvariable, is the string in which the number of characters need to be determined.

Return Value − The number of characters in the string.

Example

Following is an example of the string formatting in Clojure.

(ns clojure.examples.hello
   (:gen-class))
(defn hello-world []
   (println (count "Hello")))
(hello-world)

Output

The above program produces the following output.

5
clojure_strings.htm
Advertisements