[Top][All Lists]

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

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

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

Hi all,

Here’s a perfect example of why I keep stumbling (and stopping) when trying to 
learn Scheme+Lilypond…  =\

With Mike S’s help — read: he did it all, actually! (though I fully understand 
every part of the code) — I have the following:

\version "2.19.83"

some-music = { a'4 bes' b' aes' g' cis' d' ees' fis' f' e' c' }

#(define (zip . xss) (apply map list xss))

 (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)))
   (map (lambda (h) (- (cadr h) (car h))) (zip top bottom)))

Works great. Just what I want at this stage in the (multi-stage) procedure I’m 
trying to code.

As the next step, I want to turn this into a function and display the result in 
a markup. Result: I spend several hours searching documentation, trying 
different functions, and getting one (or more!) errors per attempt, but no 
success. I literally cannot figure out how to turn this into a string, save 
hand-coding a recursion/map that takes each element of the list and appends it 
onto a string… and if that’s actually the "correct"/"best" way to do it, then I 
deeply question my desire to code in Scheme+Lilypond at all.  ;)

So someone please tell me what simple thing I’m missing here. In the worst case 
scenario, you just give me a fish and I can eat for a little while longer 
(read: not give up); best case senario, you teach me (and anyone else reading 
this list, now or in the future in the future) how to fish.


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

reply via email to

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