lilypond-user
[Top][All Lists]
Advanced

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

Re: Using Scheme


From: Trent Johnston
Subject: Re: Using Scheme
Date: Sun, 14 May 2006 21:12:41 +1000

Thanks Nicolas that's great!!

Thanks for all your help lately it's greatly appreciated.

And thanks to all that have come to my assistance with this question.

Could this example along with the explanation from Nicholas be added to the
manual?

I think it would further the understanding of scheme especially when using
pairs of numbers as there are other overrides that require to pairs. e.g.
extra-offset.

Thanks again,

Trent


----- Original Message ----- 
From: "Nicolas Sceaux" <address@hidden>
To: "Mats Bengtsson" <address@hidden>
Cc: "Trent Johnston" <address@hidden>; "Paul Scott"
<address@hidden>; <address@hidden>
Sent: Saturday, May 13, 2006 4:37 AM
Subject: Re: Using Scheme


|
| Mats Bengtsson <address@hidden> writes:
|
| > Trent Johnston wrote:
| >
| >>Sorry I should have been a bit more specific before...
| >>
| >>I tried using
| >>
| >>manBeam = #(define-music-function (parser location beg end) (number?
| >>number?)
| >> #{ \once \override Beam #'positions = #'($beg . $end) #} )
| >>
|
| > Nicolas recently answered a closely related question.
| > One solution should be to replace
| > #'($beg . $end)
| > by
| > (cons $beg $end)
|
| To Trent:
| You need to understand that a scheme form preceded by a quote (that's
| called a quoted form) is not evaluated. Thus, something like
| '(var1 . var2) evaluates to that, (var1 . var2), eg a cons cell
| containing two symbols, var1 and var2. But what you want is a cons cell
| with two numbers, the value of the variables var1 and var2. So you
| should not quote the form, so that the variables should be evalutated.
| Instead, you make the cons cell using the function `cons':
|   (cons var1 var2) ==> (3 . 6)
| supposing that var1 and var2 respectively evaluate to 3 and 6.
|
|   manBeam =
|   #(define-music-function (parser location beg end)
|                           (number? number?)
|     #{ \once \override Beam #'positions = #(cons $beg $end) #})
|
|   \manBeam #3 #6
|
| or:
|
|   manBeam =
|   #(define-music-function (parser location beg-end)
|                           (cons?)
|     #{ \once \override Beam #'positions = #$beg-end #})
|
|   \manBeam #'(3 . 6)
|   \manBeam #(cons 3 6)
|
| nicolas
|




reply via email to

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