scheme recursion - power of an int -
i trying implement function tells if parameter power of 2. here have
(define (powof2 x) (cond [(and (even? x) (> x 1)) ((powof2 (/ x 2)))] [else (equal?(x 1))]))
but when try run parameter 12 error saying: error: 3 not function [powof2, powof2, powof2, (anon)]
any help?
thanks!
ah parenthesis ;-)
(define (powof2 x) (cond [(and (even? x) (> x 1)) (powof2 (/ x 2))] [else (= x 1)]))
note in 3rd line , 4th line had pair of parenthesis, , in 4th line should use =
compare numbers.
Comments
Post a Comment