lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing along variable-number arguments


From: David Kastrup
Subject: Re: Passing along variable-number arguments
Date: Tue, 02 Feb 2016 00:44:18 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

Urs Liska <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]