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

无涯教程-Clojure - conj函数

时间:2023-10-25 19:32:37浏览次数:29  
标签:clojure 无涯 列表 lst elementlst conj Clojure example

返回一个新列表,其中该列表位于开头,而要附加的元素位于结尾。

conj - 语法

以下是语法。

(conj lst elementlst)

参数      -  " elementlst"是需要添加到列表中的元素列表, " lst"是元素列表。

返回值  -  带有附加值的列表。

conj - 示例

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

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

(5 4 1 2 3)

参考链接

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

标签:clojure,无涯,列表,lst,elementlst,conj,Clojure,example
From: https://blog.51cto.com/u_14033984/8024384

相关文章

  • 无涯教程-Clojure - nth函数
    此函数返回列表中第"n"个位置的元素。nth-语法以下是语法。(nthlstindex)参数   - "lst"是列表。"index"是元素的索引位置,需要返回。返回值 - 列表中索引位置的值。nth-示例(nsclojure.examples.example(:gen-class))(defnexample[](pr......
  • 无涯教程-Clojure - cons函数
    返回一个新列表,其中元素添加到列表的开头。cons-语法以下是语法。(conselementlst)参数   - "element"是需要添加到列表中的元素,"lst"是项目列表。返回值 - 带有附加值的列表。cons-示例(nsclojure.examples.example(:gen-class))(defnexample......
  • 无涯教程-Clojure - first函数
    此函数返回列表中的第一项。first-语法以下是语法。(firstlst)参数   - "lst"是项目列表。返回值 - 列表中的第一个值。first-示例以下是Clojure中first的示例。(nsclojure.examples.example(:gen-class))(defnexample[](println(first(......
  • 无涯教程-Clojure - upper-case函数
    将字符串转换为全部大写。upper-case-语法以下是语法。(upper-cases)参数   - 其中"s"是要转换的字符串。返回值 - 大写字符串。upper-case-示例以下是Clojure中大写字母的示例。(nsclojure.examples.hello(:gen-class))(defnhello-Learnfk[]......
  • 无涯教程-Clojure - float?函数
    如果数字为浮点数,则返回true。float?-语法以下是语法。(float?number)float?-示例以下是浮动测试函数的示例。(nsclojure.examples.hello(:gen-class));;ThisprogramdisplaysHelloLearnfk(defnExample[](defx(float?0))(printlnx)......
  • 无涯教程-Clojure - number?函数
    如果数字确实是数字,则返回true。number?-语法以下是语法。(number?number)number?-示例以下是数字测试函数的示例。(nsclojure.examples.hello(:gen-class));;ThisprogramdisplaysHelloLearnfk(defnExample[](defx(number?0))(printlnx)......
  • 无涯教程-Clojure - odd?函数
    如果数字为奇数,则返回true;如果数字不是整数,则引发异常。odd?-语法以下是语法。(odd?number)odd?-示例以下是奇数测试函数的示例。(nsclojure.examples.hello(:gen-class));;ThisprogramdisplaysHelloLearnfk(defnExample[](defx(odd?0))(pri......
  • 无涯教程-Clojure - 循环语句函数
    循环的特殊形式不同于"for"循环。循环的用法与let绑定相同,为了使循环发生,为循环指定的参数(arity)数必须与循环的绑定数一致。Loop-语法以下是循环语句的一般语法。loop[binding](condition(statement)(recur(binding)))以下是此循环的示意图。Loop-示例......
  • 无涯教程-Clojure - 库(Libraries)
    使Clojure库如此强大的一件事是Clojure框架有很多可用的库,在前面的示例中,我们已经看到很多用于Web测试,Web开发,开发基于swing的应用程序的库,以及用于连接MySQL数据库的jdbc库,以下只是几个其他库的几个示例。date.hml该库允许Clojure处理XML数据,要使用的库版本为org.clojure/data......
  • 无涯教程-Clojure - 原子(Atoms)
    Atoms原子是Clojure中的一种数据类型,提供了一种管理共享,同步,独立状态的方法,原子就像任何其他编程语言中的任何引用类型一样。原子的主要用途是保存Clojure的不可变数据结构。原子是通过atom方法创建的。(nsclojure.examples.example(:gen-class))(defnexample[](de......