该函数用于定义所需的结构。
(defstruct structname keys)
参数 - " structname"是要赋予结构的名称, "keys"是需要作为结构一部分的键。
返回值 - 返回结构对象 。
以下程序显示了有关如何使用它的示例。
(ns clojure.examples.example (:gen-class)) (defn Example [] (println (defstruct Employee :EmployeeName :Employeeid))) (Example)
请注意,以上函数仅用于创建您的结构,我们将看到更多可用于结构的函数。
链接:https://www.learnfk.comhttps://www.learnfk.com/clojure/clojure-defstruct.html
来源:LearnFk无涯教程网
上面的程序产生以下输出。
#'clojure.examples.example/Employee
这一章《Clojure - StructMaps - defstruct 函数》你学到了什么?在下面做个笔记吧!做站不易,你的分享是对我们最大的支持