gpt4 book ai didi

clojure - 无法获取宏的值(clojure)

转载 作者:行者123 更新时间:2023-12-04 01:55:16 26 4
gpt4 key购买 nike

在这一段clojure代码中:

(defn makeStructs ;line 27
"open fName as a file and turns each line into a struct. Returns a Vector of structs"
[fName]
with-open[r (reader (file fName))]
(let [r
res (doall (map makeStruct (line-seq r)))
]
(. r close)
res
)
)

我收到此编译器错误:
Exception in thread "main" java.lang.Exception: Can't take value of a macro: #'clojure.core/with-open (clojureHW.clj:27)

上面注释了第 27 行。

知道问题是什么吗?

最佳答案

你需要实际调用宏,

(defn makeStructs ;line 27
"..."
[fName]
(with-open ; note the extra paren

关于clojure - 无法获取宏的值(clojure),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5751262/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com