Clojure - 字符串计数



要查找字符串中的字符数,可以使用 count 函数。

语法

以下是语法。

(count stringvariable)

参数 − ‘Stringvariable,是要确定字符数的字符串。

返回值 − 字符串中的字符数。

示例

以下是 Clojure 中字符串格式化的示例。

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

输出

以上程序产生以下输出。

5
clojure_strings.htm
广告

© . All rights reserved.