【发布时间】:2012-08-24 04:56:59
【问题描述】:
在“Clojure in Action”(第 63 页)中处理以下示例:
(defn basic-item-total [price quantity]
(* price quantity))
(defn with-line-item-conditions [f price quantity]
{:pre [(> price 0) (> quantity 0)]
:post [(> % 1)]}
(apply f price quantity))
在 REPL 上进行评估:
(with-line-item-conditions basic-item-total 20 1)
导致以下异常被抛出:
Don't know how to create ISeq from: java.lang.Long
[Thrown class java.lang.IllegalArgumentException]
似乎在评估应用程序后引发了异常。
【问题讨论】:
-
apply是一个函数,而不是宏。
标签: exception clojure higher-order-functions first-class-functions