lilypond-user
[Top][All Lists]
Advanced

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

Re: Scheme: Syntax for storing a variable in an alist


From: Aaron Hill
Subject: Re: Scheme: Syntax for storing a variable in an alist
Date: Sun, 18 Oct 2020 12:58:02 -0700
User-agent: Roundcube Webmail/1.4.9

On 2020-10-18 12:42 pm, Matthew Fong wrote:
Hello everyone,

I am having a bit of an issue storing a variable in an alist, and I was
wondering if you all could point out what I am doing wrong. If I write the
string directly, there's no issue retrieving it ...

my-alist = #'((1  . "A") (2 . "B") (3 . "C"))
value = #(ly:assoc-get 2 my-alist " error")
\markup \value

hymnID = "210"
hymnMeter = "8.8.8.8"
hymnAlist = #'(("ID" . \hymnID ) ("Meter" . \hymnMeter ))
hymnValue = #(ly:assoc-get "ID" hymnAlist "error")
\markup \hymnValue

Jean already covered the bit about quasi-quoting.

But there is no need to do this as you can store values in an alist using dot syntax in LilyPond:

%%%%
hymn.id = "643"
hymn.meter = "6 6 11 6 6 11 D"
\markup #(ly:assoc-get 'id hymn "no value")
\markup #(ly:assoc-get 'tune hymn "no value")
%%%%

\hymn automatically is an alist.


-- Aaron Hill



reply via email to

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