该函数用于定义所需的结构。
(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
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)