Arc Forumnew | comments | leaders | submitlogin
3 points by cchooper 6056 days ago | link | parent

You don't need to nest if expressions in Arc, you can do this:

  (if a b
      c d
      e f
      g)
For defining power, it's easier to use a recursive function:

  (def power (n p)
    (if (is p 0) 1
        (> p 0)  (* n (power n (- p 1)))
        (/ 1 (power n (* -1 p)))))
If you want to use for then the problem is indeed (for x 0 power -1). for only counts up, so (= acc (/ acc nbr)) never gets executed because 0 is already greater than power.

Instead, try counting the other way around:

  (for x power 0
    (= acc (/ acc nbr)))