我正在开发一个包含以下代码行的clojure程序:
(defn makeStruct
"Take a line of input and return a starbucks-struct"
[input]
(let[(apply struct storeinfo (clojure.string/split input #","))]
)
Run Code Online (Sandbox Code Playgroud)
)
我得到这个编译器错误:
Exception in thread "main" java.lang.IllegalArgumentException: let requires an even number of forms in binding vector (clojureHW.clj:24)
Run Code Online (Sandbox Code Playgroud)
我对clojure很新,并不完全确定我在做什么,但在这种情况下,输入是一个字符串,我将它拆分为一个向量来初始化我的结构.我使用的语法let
不正确吗?
let需要偶数个表单,因为它将值绑定到本地:
(let [x 10,
y (+ x 20)]
; do something with x and y here
(* x y))
Run Code Online (Sandbox Code Playgroud)
请阅读此处的文档:http: //clojure.org/special_forms#Special%20Forms--(let%20%5Bbindings*%20%5D%20exprs*)
归档时间: |
|
查看次数: |
2884 次 |
最近记录: |