lilypond-user
[Top][All Lists]
Advanced

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

Re: Scheme: passing arguments to music-function?


From: David Kastrup
Subject: Re: Scheme: passing arguments to music-function?
Date: Fri, 22 Nov 2013 00:46:46 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Graham King <address@hidden> writes:

> I'm trying, in a somewhat haphazard way, to learn some more Scheme, but
> I'm clearly not reading the right stuff to solve the following problem.
> Please can someone point me in the right direction.
>
> I have the following function (hugely abbreviated here):
>
> foo = #(define-music-function( P L arg1 arg2 arg3 ... )
>                              (type1? type2? type3? ... )
>           #{
>               \mark \markup {
>                                 % bunch of stuff
>                             }
>           #}
>        )
>
> I would like to pass an argument, arg4 say, equal to "system" or
> "staff".
> \mark would be replaced by a parameter taking the values:
> \mark if arg4 == "system", and
> <>^ if arg4 == "staff"

Assuming a reasonably recent version of 2.17, use the predicate symbol?
for the type.  The whole construct for your cases is sufficiently
different that it's probably easiest to do the body as

(let ((bunch #{ \markup { bunch of stuff } #}))
  (case arg4
    ((system) #{ \mark #bunch #})
    ((staff) #{ <>^ #bunch #})
    (else #{ \mark \markup \color #red #bunch })))

-- 
David Kastrup




reply via email to

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