ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn

前端 未结 4 1786
一向
一向 2020-12-30 19:17

I have a function that takes the number of years and salary, then recursively doubles the salary until years is exhausted. However, I keep getting this error:

4条回答
  •  猫巷女王i
    2020-12-30 20:10

    The error's meaning shouldn't be too hard to sort out: a number is being used where a function is expected.

    Parenthesis in Clojure are not a grouping construct, they are used primarily to invoke function calls. If you change (salary) to salary you will return the number rather than attempting to call it as a no-argument function.

提交回复
热议问题