首页 > 其他分享 >无涯教程-Clojure - conj函数

无涯教程-Clojure - conj函数

时间:2023-10-27 14:33:17浏览次数:41  
标签:clojure seq 元素 无涯 序列 conj Clojure Example

返回一个新序列,其中" x"是添加到序列末尾的元素。

conj - 语法

以下是语法。

(conj seq x)

参数      -  " x"是需要添加到序列中的元素。 " seq"是元素的顺序列表。

返回值  -  具有附加元素的新序列。

conj - 示例

(ns clojure.examples.example
   (:gen-class))

;; This program displays Hello Learnfk
(defn Example []
   (println (conj [1 2 3] 4)))
(Example)

上面的程序产生以下输出。

(1 2 3 4)

参考链接

https://www.learnfk.com/clojure/clojure-sequences-conj.html

标签:clojure,seq,元素,无涯,序列,conj,Clojure,Example
From: https://blog.51cto.com/u_14033984/8056282

相关文章

  • 无涯教程-Clojure - cons函数
    返回一个新序列,其中"x"是第一个元素,而"seq"是其余元素。cons-语法以下是语法。(consxseq)参数   - "x"是需要添加到序列中的元素。"seq"是元素的顺序列表。返回值 - 具有附加元素的新序列。cons-示例以下是Clojure中con的示例。(nsclojure.examp......
  • 无涯教程-Clojure - ns-name函数
    返回特定名称空间的名称。ns-name-语法以下是语法。(ns-namenamespace-name)参数   - "namespace-name"是需要找到的名称空间。返回值 - 名称空间的实际名称。ns-name-示例(nsclojure.examples.example(:require[clojure.set:asset])(:gen-c......
  • 无涯教程-Clojure - select-keys函数
    返回包含键的值。select-keys-语法以下是语法。(select-keyshmapkeys)参数   - "hmap"是哈希键和值的映射。"keys"是需要从HashMap中选择的键列表。返回值 - 根据键的select子句从映射返回键。select-keys-示例(nsclojure.examples.example(:gen......
  • 无涯教程-Clojure - merge-with函数
    返回由映射到第一个映射的其余映射组成的映射,如果一个键出现在多个Map中,则来自后者的映射(从左到右)将与输出中的映射合并。merge-with-语法以下是语法。(merge-withfhmap1hmap2)参数   - "f"是需要应用于哈希映射的运算符,"hmap1"是哈希键和值的映射,"hmap2......
  • 无涯教程-Clojure - vals函数
    返回映射中的值列表。vals-语法以下是语法。(valshmap)参数   - "hmap"是哈希键和值的映射。返回值 - 返回映射中的值列表。vals-示例(nsclojure.examples.example(:gen-class))(defnexample[](defdemokeys(hash-map"z""1""b""2"&......
  • 无涯教程-Clojure - keys函数
    返回Map中的键列表。keys-语法以下是语法。(keyshmap)参数   -  "hmap"是哈希键和值的映射。返回值 - 返回Map中的键列表。keys-示例(nsclojure.examples.example(:gen-class))(defnexample[](defdemokeys(hash-map"z""1""b""2"......
  • 无涯教程-Clojure - pop函数
    对于列表或队列,返回没有第一项的新列表/队列,对于向量,返回没有最后一项的新向量。pop-语法以下是语法。(popvec)参数   - "vec"是元素的向量集。返回值 - 返回不带最后一项的新向量。pop-示例(nsclojure.examples.example(:gen-class))(defnexamp......
  • 无涯教程-Clojure - superset?函数
    判断set1是否是set2的超集。superset?-语法以下是语法。(superset?set1set2)参数   - "set1"是第一组元素,"set2"是第二组元素。返回值 - 如果set1是set2的超集,则为true,否则为false。superset?-示例(nsclojure.examples.example(:require[cloju......
  • 无涯教程-Clojure - conj函数
    返回一个新列表,其中该列表位于开头,而要附加的元素位于结尾。conj-语法以下是语法。(conjlstelementlst)参数   - "elementlst"是需要添加到列表中的元素列表,"lst"是元素列表。返回值 - 带有附加值的列表。conj-示例(nsclojure.examples.example......
  • 无涯教程-Clojure - nth函数
    此函数返回列表中第"n"个位置的元素。nth-语法以下是语法。(nthlstindex)参数   - "lst"是列表。"index"是元素的索引位置,需要返回。返回值 - 列表中索引位置的值。nth-示例(nsclojure.examples.example(:gen-class))(defnexample[](pr......