Urs Liska <u...@openlilylib.org> writes:

> Hi,
>
> I'm hitting a wall with Scheme once more.
> I need to create wrapper functions around (format) and other functions
> that need a variable number of arguments.
>
> I know that with
>
>     #(define (my-proc fmt . vals)
>
> "vals" will be an arbitrary number of arguments that will be wrapped in
> a list, and I know how to access the individual items or this list from
> within the function. But what I don't understand is how to pass exactly
> the original arguments (*not* packed in a list) to another function in
> the body:
>
> %%%%%%%%%%%%%%%%%%%%%%%
>
> \version "2.19.35"
>
> #(define (wrapper fmt . vals)
>    (ly:message (format fmt vals)))
>
> #(wrapper "This is the ~a format string\n" "listified")
> %#(wrapper "This is the ~a and ~a format string\n" "listified" "broken")
>
> %%%%%%%%%%%%%%%%%%%%%%%
>
> In this code "format" receives "fmt" (the format strings) and "vals" -
> the *list* of arguments.
> How should I modify this so "format" doesn't parenthesize the output and
> also works with more than one argument and placeholder in the format string?

(apply format fmt vals)

-- 
David Kastrup

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to