There is a `pow` function in core.matrix, that computes powers over whole arrays at the same time.
Tests / patches to improve this always welcome. On Tuesday, 3 June 2008 16:55:15 UTC+8, Jon wrote: > > As I could not find a ** function in boot.clj, I wrote this one: > > (defn ** > "nth power of x" > [x n] > (if (== n 0) > 1 > (* (if (bit-test n 0) x 1) > (** (* x x) (bit-shift-right n 1)) ) ) ) > > In my opinion, it has one weakness: It loops forever when n<0, like in > (** 2 -3). The reason is that (bit-shift-right -1 1) returns -1. > If anybody knows a faster/better Clojure power function, let me > know. ;-) > > /Jon -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.