variable length argument lists
Posted: Wed Sep 22, 2004 2:12 am
Without resorting to define-macro and (args) what
is the preferred idiom for specifying a function
taking a variable number of arguments?
Do you simply have to anticipate these optional arguments?
(define (foo x y z) ...)
But if this is the case than passing this variable number
of arguments onto another such function such as a native
function is problematic.
(define (foo x y z) (+ x y z)) ;; no good if y or z is nil
Do I have to resort to prepacking my arguments into an array.
(define (foo x optargs-list)
(apply + (cons x optargs-list)))
is the preferred idiom for specifying a function
taking a variable number of arguments?
Do you simply have to anticipate these optional arguments?
(define (foo x y z) ...)
But if this is the case than passing this variable number
of arguments onto another such function such as a native
function is problematic.
(define (foo x y z) (+ x y z)) ;; no good if y or z is nil
Do I have to resort to prepacking my arguments into an array.
(define (foo x optargs-list)
(apply + (cons x optargs-list)))