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.