Arc Forumnew | comments | leaders | submitlogin
Function call on inappropriate object 5
1 point by globalrev 6064 days ago | 1 comment
(def fac(n) (if (is n 0) 1 (* n (fac(- n 1)))))

(def hyfac(n) (let y 1 (for x 1 (+ n 1) (= y (* y fac(n))))))

#<procedure: hyfac> arc> (hyfac 5) Error: "Function call on inappropriate object 5 ()" arc>

meh, why isnt that working?



4 points by skenney26 6064 days ago | link

It looks like the final left paren in hyfac is misplaced. It needs to be before the call to fac. Also, unless you explicity return y, hyfac will just return nil.

  (def hyfac (n)
    (let y 1
      (for x 1 (+ n 1)
        (= y (* y (fac n))))
    y))

-----