[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Questions about using Scheme with Lilypond
From: |
Aaron Hill |
Subject: |
Re: Questions about using Scheme with Lilypond |
Date: |
Mon, 16 Nov 2020 11:47:11 -0800 |
User-agent: |
Roundcube Webmail/1.4.9 |
On 2020-11-16 10:28 am, Tom Brennan wrote:
Re: arity, the (admittedly unclear) question wasn't whether or not
scheme
supports multi-arity, but whether you can "splat" any list (doesn't
have to
be from args), into a block of lilypond code, i.e.,
The list splicing operators [1] are likely what you need to use:
[1]:
http://lilypond.org/doc/v2.21/Documentation/extending-big-page.html#importing-scheme-in-lilypond
%%%%
\version "2.20.0"
foo = #(music-pitches #{ b' g' a' #})
{ g'4. #@(map (lambda (p) #{ $p 8 #}) foo) b'4 $@(reverse foo) 2 }
%% \_________________________________/ \_____________/
{ g'4. b'8 g'8 a'8 b'4 a' g' b' 2 }
%%%%
While the above deals with a list of pitches, here is another example
involving scores:
%%%%
\version "2.20.0"
baz = #(list #{ \score { { b'1 } } #}
#{ \score { { g'4 a'2. } } #}
#{ \score { { b'4. g'8 a'2 } } #})
\bookpart { $@baz }
#(define (score->markup score)
#{ \markup \score { #score \layout { indent = 0 } } #})
\markup { Lorem ipsum #@(map score->markup baz) dolor sit amet. }
%%%%
-- Aaron Hill