输出参数

函数

;; Clojure 中参数无法修改:没有 "out" 参数。
;; 答案通过返回值离开函数
(defn get-sum [n1 n2]
  (+ n1 n2))

(def sum (get-sum 5 3))
;; sum is 8
(println "sum is" sum)

;; 一次得到两个答案时,用向量返回并解构
(defn divide [a b]
  [(quot a b) (rem a b)])

(let [[quotient remainder] (divide 17 5)]
  (println "quotient is" quotient)
  (println "remainder is" remainder))