;; Clojure 没有泛型,因为它没有静态类型:
;; 函数接受传入的任何值,因此无需参数化。
;; 同一个映射适用于任何类型的尺寸
(defn size [width height] {:width width, :height height})
(defn as-text [s] (str "[" (:width s) "; " (:height s) "]"))
(def text-int (as-text (size 5 8)))
;; text-int is "[5; 8]"
(def text-float (as-text (size 3.7 1.58)))
;; text-float is "[3.7; 1.58]"
(println "text-int is" text-int)
(println "text-float is" text-float)
(println "text-mixed is" (as-text (size "wide" :tall)))