lilypond-devel
[Top][All Lists]
Advanced

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

Re: TimeSignature with note in denominator


From: Aaron Hill
Subject: Re: TimeSignature with note in denominator
Date: Fri, 12 Nov 2021 17:10:40 -0800
User-agent: Roundcube Webmail/1.4.9

On 2021-11-12 4:22 pm, Kieren MacMillan wrote:
except that the Scheme expressions
'("4" . ("4" "8"))
and
'("4" "4" "8")
are entirely equivalent

Well that’s inconvenient (and somewhat confusing/unintuitive).

When you consider how lists are represented in Scheme, this is entirely expected.

A list is formed by cons-ing the first element of the list with a list containing the rest of the elements. (This is why a list is also considered a pair.) Note this construction is recursive, with the list containing the rest of the elements being built in the same manner. At some point, you will have the last element of the list. This needs to be cons-ed to something, in particular the null or empty list as there are no other elements after the last one.

Manually specifying a list in this way is possible, albeit a little verbose. Using list or the quote shorthand makes for less typing, but it is useful to always think of the long form as what is going on.

;;;;
(cons 'lorem (cons 'ipsum (cons 'dolor (cons 'sit (cons 'amet '())))))

(list 'lorem 'ipsum 'dolor 'sit 'amet)

'(lorem ipsum dolor sit amet)
;;;;

The quote shorthand, by the by, makes a distinction between a list and a pair by use of a period for denoting paired elements. Also while proper lists terminate with the null list, it is possible to construct a so-called "dotted list" that does not.

;;;;
'(a . b)    ; =>  (cons 'a 'b)
'(a b)      ; =>  (cons 'a (cons 'b '()))

'(a b . c)  ; =>  (cons 'a (cons 'b 'c))
;;;;

The main takeaway here is that cons-ing an atom and a list with the intent to create a pair will also result in creating a new list. Scheme does not make any distinction.


-- Aaron Hill



reply via email to

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