lilypond-user
[Top][All Lists]
Advanced

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

Re: Use functions within functions


From: Jan-Peter Voigt
Subject: Re: Use functions within functions
Date: Tue, 08 Jan 2013 12:43:05 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0

Hi Noeck,

here's a little snippet with a nonsense-function, embedding one function in another in two ways:

%--snip--
\version "2.16.1"

% define a music function
funA = #(define-music-function (parser location x y)(number? number?)
          (ly:input-message location "I am here!")
(make-music 'TextScriptEvent 'tweaks `((extra-offset . (,x . ,y))) 'text "H"))

% embed funA with embedded lily -> location is pointing to funA call inside this function
funB = #(define-music-function (parser location)()
          #{ \funA #0 #-2 #})

% embed funA as a scheme function -> location is pointing to funC call
funC = #(define-music-function (parser location)()
          (let ((fun-a (ly:music-function-extract funA)))
            (fun-a parser location 0 -2)))

{ c'' \funA #0 #-2 c'' \funB c'' \funC c'' }
%--snip--

HTH
Cheers, Jan-Peter

Am 08.01.2013 12:00, schrieb Noeck:
Hi,

how can I use a self-defined function with in another one?

I tried the following pseudo-code, but then myfunc is no valid function
name in the scope of the second function.


------ly-file-------------------------------

#(… scheme function definition of function myfunc …)


#(… function-head …
   #{ … lilypond-code … #(myfunc arg)  … #}

------end-ly-file---------------------------


(I have not yet tried putting both functions in one #(…) but I want to
be able to distribute the function definition over different files.)

Cheers,
Joram

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





reply via email to

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