(define stuff '(lambda (x) (+ x x))) (define sect (lambda (proc . lst) (letrec ((make-param (lambda (num) (string->symbol (string-append "_p_" (number->string num))))) (make-func (lambda (count lst newparams newbody) (cond ((null? lst) (list 'lambda (reverse newparams) (cons proc (reverse newbody)))) ((eq? '? (car lst)) (make-func (+ count 1) (cdr lst) (cons (make-param count) newparams) (cons (make-param count) newbody))) (else (make-func count (cdr lst) newparams (cons (car lst) newbody))))))) (make-func 0 lst null null)))) (define section (lambda stuff (eval (apply sect stuff)))) (define foo (lambda (a b) (+ (* a a) (* b b)))) ;Some interesting examples to try in the interactions window: ;(define bar (section foo '? 2)) ;(define baz (section 'foo '? 2)) ;(bar 3) ;(baz 3) ;(define foo +) ;(bar 3) ;(baz 3)