Arc Forumnew | comments | leaders | submitlogin
1 point by tokipin 6000 days ago | link | parent

take a look at http://arcfn.com/doc/iteration.html for a list of different iteration functions. since you aren't using the x variable in those for loops there, you could just use repeat:

  (repeat (abs pow) ... )
here's my version:

  (def power (nbr pow)
     (withs (acc 1.0
             power+ (fn (times)
                        (repeat times
                            (zap * acc nbr))
                        acc))
            (if
              (> pow 0)
                    (power+ pow)
              (< pow 0)
                    (/ 1 (power+ (- pow)))
              1)))