[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to define functions that generate music functions?
From: |
Carl Sorensen |
Subject: |
Re: How to define functions that generate music functions? |
Date: |
Wed, 15 Dec 2010 11:35:32 -0700 |
On 12/15/10 9:29 AM, "Juha Erkkila" <address@hidden> wrote:
> Is it possible to define functions that generate music functions
> in Lilypond? I'm looking something to this effect:
>
> -----
> \version "2.12.3"
>
> musicA = #(define-music-function (parser location music)
> (ly:music?)
> #{ c4 d e f $music #})
>
> \musicA { g4 a b a }
>
> % makeMusicFn = #(define-music-function (parser location prepend-music)
> % (ly:music?)
> % (define-music-function (parser location append-music)
> % (ly:music?)
> % #{ $prepend-music $append-music #}))
> %
> % musicB = \makeMusicFn { c4 d e f }
> %
> % \musicB { g4 a b a }
> -----
>
> Here expressions "\musicA { g4 a b a }" and "\musicB { g4 a b a }"
> should evaluate to same music expression, that is
> { c4 d e f g4 a b a }. The expressions that are commented out are
> attempts to achieve what I'm looking for. The above syntax is,
> however, wrong, as define-music-function must return a music
> expression, not a function.
Music functions must return music expressions, but scheme functions can
return functions.
Are you after this specific behavior, or some other behavior, of which this
is a simplified example?
Thanks,
Carl