[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lilypond-user
Subject:    Re: scheme function generating multiple score
From:       Gianmaria Lari <gianmarialari () gmail ! com>
Date:       2017-12-29 12:49:05
Message-ID: CAKhGe3wb74ie07TaoFdY3wQXKk2JaP+qyzVNugxqaTs=TSK-TQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On 29 December 2017 at 12:28, Gianmaria Lari <gianmarialari@gmail.com>
wrote:

>
>
> On 29 December 2017 at 11:26, Timothy Lanfear <timothy@lanfear.me> wrote:
>
>> On 29/12/17 07:03, Gianmaria Lari wrote:
>>
>>> Sorry to bother but I'm unable to get out from this problem.
>>> This code generate two scores:
>>>
>>>     \version "2.19.80"
>>>
>>>     \score {
>>>       \transpose c d {c' d' e'}
>>>       \layout{}
>>>     }
>>>
>>>     \score {
>>>       \transpose c e {c' d' e'}
>>>       \layout{}
>>>     }
>>>
>>> I tried to write a scheme function doing something similar:
>>>
>>>     \version "2.19.80"
>>>     myScore = #(define-scheme-function (music) (ly:music?) #{
>>>
>>>     \score {
>>>       \transpose c d $music
>>>       \layout{}
>>>     }
>>>
>>>     \score {
>>>       \transpose c e $music
>>>       \layout{}
>>>     }
>>>
>>>     #})
>>>
>>>     \myScore {c' d' e'}
>>>
>>> but when I try to compile I get this error
>>>
>>>
>>>     error: syntax error, unexpected \score, expecting end of input
>>>
>>>     \score {
>>>
>>>
>>>     error: error in #{ ... #}
>>>
>>>
>>> Any suggestion?
>>> Thank you, Gianmaria
>>>
>>>
>> A function can only return a single item so you could wrap the two scores
>> in a book and then process the book.
>>
>> \version "2.19.80"
>>
>> myBook = #(define-scheme-function (music) (ly:music?) #{
>>   \book {
>>     \score { \transpose c d $music \layout{} }
>>     \score { \transpose c e $music \layout{} }
>>   }
>> #})
>>
>> mybook = #(myBook #{ { c' d' e' } #})
>> \mybook
>>
>>
>>
>>
>>
>> --
>> Timothy Lanfear, Bristol, UK.
>>
>>
>> _______________________________________________
>> lilypond-user mailing list
>> lilypond-user@gnu.org
>> https://lists.gnu.org/mailman/listinfo/lilypond-user
>>
>
> oh, great! It was some weeks I was stuck with this issue. I thought the
> scheme function would simply copy everything inside the #{ ... #} replacing
> the variable.
>
> Thanks a lot Timothy!
>

Is it possible to avoid the two lines

mybook = #(myBook #{ { c' d' e' } #})
\mybook

and write directly something like

.... myBook #{ { c' d' e' } #}

?

[Attachment #5 (text/html)]

<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 29 \
December 2017 at 12:28, Gianmaria Lari <span dir="ltr">&lt;<a \
href="mailto:gianmarialari@gmail.com" \
target="_blank">gianmarialari@gmail.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div \
class="gmail-h5"><div><br></div><div class="gmail_extra"><br><div \
class="gmail_quote">On 29 December 2017 at 11:26, Timothy Lanfear <span \
dir="ltr">&lt;<a href="mailto:timothy@lanfear.me" \
target="_blank">timothy@lanfear.me</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"><div \
class="gmail-m_-3461276824148050086gmail-HOEnZb"><div \
class="gmail-m_-3461276824148050086gmail-h5">On 29/12/17 07:03, Gianmaria Lari \
wrote:<br> <blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> Sorry to bother but \
I&#39;m unable to get out from this problem.<br> This code generate two scores:<br>
<br>
      \version &quot;2.19.80&quot;<br>
<br>
      \score {<br>
         \transpose c d {c&#39; d&#39; e&#39;}<br>
         \layout{}<br>
      }<br>
<br>
      \score {<br>
         \transpose c e {c&#39; d&#39; e&#39;}<br>
         \layout{}<br>
      }<br>
<br>
I tried to write a scheme function doing something similar:<br>
<br>
      \version &quot;2.19.80&quot;<br>
      myScore = #(define-scheme-function (music) (ly:music?) #{<br>
<br>
      \score {<br>
         \transpose c d $music<br>
         \layout{}<br>
      }<br>
<br>
      \score {<br>
         \transpose c e $music<br>
         \layout{}<br>
      }<br>
<br>
      #})<br>
<br>
      \myScore {c&#39; d&#39; e&#39;}<br>
<br>
but when I try to compile I get this error<br>
<br>
<br>
      error: syntax error, unexpected \score, expecting end of input<br>
<br>
      \score  {<br>
<br>
<br>
      error: error in #{ ... #}<br>
<br>
<br>
Any suggestion?<br>
Thank you, Gianmaria<br>
<br>
</blockquote>
<br></div></div>
A function can only return a single item so you could wrap the two scores in a book \
and then process the book.<br> <br>
\version &quot;2.19.80&quot;<br>
<br>
myBook = #(define-scheme-function (music) (ly:music?) #{<br>
   \book {<span class="gmail-m_-3461276824148050086gmail-"><br>
       \score { \transpose c d $music \layout{} }<br>
       \score { \transpose c e $music \layout{} }<br>
   }<br>
#})<br>
<br></span>
mybook = #(myBook #{ { c&#39; d&#39; e&#39; } #})<br>
\mybook<span class="gmail-m_-3461276824148050086gmail-HOEnZb"><font \
color="#888888"><br> <br>
<br>
<br>
<br>
<br>
-- <br>
Timothy Lanfear, Bristol, UK.<br>
<br>
<br>
______________________________<wbr>_________________<br>
lilypond-user mailing list<br>
<a href="mailto:lilypond-user@gnu.org" target="_blank">lilypond-user@gnu.org</a><br>
<a href="https://lists.gnu.org/mailman/listinfo/lilypond-user" rel="noreferrer" \
target="_blank">https://lists.gnu.org/mailman/<wbr>listinfo/lilypond-user</a><br> \
</font></span></blockquote></div><br></div></div></div><div class="gmail_extra">oh, \
great! It was some weeks I was stuck with this issue. I thought the scheme function \
would simply copy everything inside the #{ ... #} replacing the \
variable.<div><br></div><div><span style="font-size:12.8px">Thanks a lot \
Timothy!</span></div></div></div> </blockquote></div><br></div><div \
class="gmail_extra">Is it possible to avoid the two lines</div><div \
class="gmail_extra"><br></div><blockquote style="margin:0 0 0 \
40px;border:none;padding:0px"><div class="gmail_extra"><span \
style="color:rgb(80,0,80)">mybook = #(myBook #{ { c&#39; d&#39; e&#39; } \
#})</span></div><div class="gmail_extra"><span \
style="color:rgb(80,0,80)">\mybook</span></div><div class="gmail_extra"><span \
style="color:rgb(80,0,80)"><br></span></div></blockquote><div \
class="gmail_extra"><span style="color:rgb(80,0,80)">and write directly something \
like</span></div><div class="gmail_extra"><span \
style="color:rgb(80,0,80)"><br></span></div><div class="gmail_extra"><span \
style="color:rgb(80,0,80)">.... myBook #{ { c&#39; d&#39; e&#39; } #}</span><span \
style="color:rgb(80,0,80)"><br></span></div><div class="gmail_extra"><span \
style="color:rgb(80,0,80)"><br></span></div><div class="gmail_extra">?</div><div \
class="gmail_extra"><br></div></div>



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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic