Clojure - 列表 conj



返回一個新的列表,其中列表位於開頭,要附加的元素位於末尾。

語法

以下是語法。

(conj lst elementlst)

引數 - 'elementlst' 是需要新增到列表中的專案列表。'lst' 是專案列表。

返回值 - 附加了值的列表。

示例

以下是 Clojure 中 cons 的示例。

(ns clojure.examples.example
   (:gen-class))
(defn example []
   (println (conj (list 1 2,3) 4 5)))
(example)

輸出

以上程式產生以下輸出。

(5 4 1 2 3)
clojure_lists.htm
廣告

© . All rights reserved.