tags:

views:

29

answers:

0

I'm a bit of a scheme newbie and I'm trying to do write a function that takes a function name, and and an expression and binds the function name as the first argument of the expression.

IE:

Something like:

(bind-function-name '+ '(param 'a "First"))

Would produce a lambda that evaluates

(param '+ 'a "First")

Best I've come up with so far:

(define (bind-function-name name cmd) 
  (let ((func (car cmd)) (args (cdr cmd)))
    (lambda ()
      (apply func (cons name args)))))

Which doesn't seem to work, as it complains about the function name being a symbol.

I'm sure this is pretty simple, but I'm just missing something, thought someone could help me out.