要查找字符串中的字符數(shù),可以使用count函數(shù)。
以下是count的基本使用語法:
(count stringvariable)
參數(shù)? 'Stringvariable,是需要確定字符數(shù)的字符串。
返回值 ? 字符串中的字符數(shù)。
下面是count函數(shù)的示例:
(ns clojure.examples.hello (:gen-class)) (defn hello-world [] (println (count "Hello"))) (hello-world)
以上示例將輸出以下結(jié)果:
5
更多建議: