[Top][All Lists]

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

Re: [Scheme coding] turning a list into a markup/string

From: Kieren MacMillan
Subject: Re: [Scheme coding] turning a list into a markup/string
Date: Tue, 21 Jan 2020 16:05:16 -0500

Hi David,

> \version "2.19"
> some-music = { a'4 bes' b' aes' g' cis' d' ees' fis' f' e' c' }
> #(define (zip . xss) (apply map list xss))
> #(define-markup-command (pitch-info layout props args) (ly:music?)
>   (let* ((res (map
>                (lambda (foo) (ly:pitch-semitones (ly:music-property
> foo 'pitch)))
>                (ly:music-property some-music 'elements)))
>          (top (reverse (cdr (reverse res))))
>          (bottom (cdr res))
>          (ls (map
>               (lambda (h) (- (cadr h) (car h)))
>               (zip top bottom)))
>          (markups (map
>                    (lambda (elt) (make-simple-markup (number->string elt)))
>                    ls)))
>     (interpret-markup layout props #{ \markup \line #markups #})))
> \markup \pitch-info #some-music

Okay, that’s basically what I was going to do "in the worst case situation".

1. I *was* hoping there was a "list->markup" macro/function somewhere…  ;)

2. I have to admit that the final "build", i.e. 

> (markups (map
>                    (lambda (elt) (make-simple-markup (number->string elt)))
>                    ls)))
>     (interpret-markup layout props #{ \markup \line #markups #})))

is more compact than I had feared'; is usually true of the [good] Scheme code I 
come across.

3. I’m pretty sure I would have taken quite a while to find my way to 
"make-simple-markup" and "interpret-markup" — thanks for showing me that part 
of the fishing tackle box!

> Hope this gets you started with whatever dodecaphonic plans you have...


This dodecaphonic stuff is just an offshoot of one of my Salzburg sessions, 
which I’m using (because of its familiarity and proximity) as a way to 
jumpstart my Scheme learning process.

Don’t worry: I’m not [currently] planning to rebuild Abjad in Scheme.  ;)


Kieren MacMillan, composer (he/him/his)
‣ website:
‣ email: address@hidden

reply via email to

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