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.