#lang scheme (provide define-recursive) #| To define a function recursing on only certain arguments, others fixed. (define-recursive ( . ) (on . ) . ) is publically like (define ( . ) . ), internally recurses by calling with just parameter(s) . Works for (at least): non-curried, any (extended) formals spec, a non-extended (no keyword/default) formals spec with names from . In particular, can have a rest parameter from *any* of the names. TODO: curried form, extensions compare with rec |# (define-syntax define-recursive (syntax-rules (on) ; Some implementation choices for first clause are for symmetry with second. [(_ ( ...) (on ...) . ) (define ( ...) (define ( ...) . ) ( ...))] [(_ ( ... . ) (on ... . ) . ) (define ( ... . ) (define ( ... . ) . ) (apply ... ))]))