How to do exponentiation in clojure?

前端 未结 13 2102
执笔经年
执笔经年 2021-01-30 12:32

How can I do exponentiation in clojure? For now I\'m only needing integer exponentiation, but the question goes for fractions too.

13条回答
  •  情书的邮戳
    2021-01-30 12:45

    How about clojure.contrib.genric.math-functions

    There is a pow function in the clojure.contrib.generic.math-functions library. It is just a macro to Math.pow and is more of a "clojureish" way of calling the Java math function.

    http://clojure.github.com/clojure-contrib/generic.math-functions-api.html#clojure.contrib.generic.math-functions/pow

提交回复
热议问题