runners3431
runners3431

Reputation: 1455

what's wrong with my higher order procedure?

I can't figure out why my lambda is wrong. It should create a make-exp.

(define (exp b n)
    (if (n = 0) 
        1
        (* b (exp b (- n 1)))))

(define make-exp (lambda(n) (lambda(b)(exp b n ))))

(define square (make-exp 2))

(square 3)

Error: 2 is not a function [square, exp, (anon)]

Upvotes: 0

Views: 38

Answers (1)

sepp2k
sepp2k

Reputation: 370415

(n = 0)

This calls the function n with the arguments = and 0, except n is 2 and not a function, so this does not work. Presumably you meant (= n 0).

Upvotes: 5

Related Questions