[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scheme function for alternate tagged swing stopped working
From: |
Christopher R. Maden |
Subject: |
Re: Scheme function for alternate tagged swing stopped working |
Date: |
Thu, 25 Dec 2014 03:01:24 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 |
On 12/24/2014 11:15 PM, I wrote:
> I’m trying to figure out a generic way to do a *shallow* copy of
> heterogeneous structures (i.e., to traverse and copy unmodified as a
> starting point, before introducing the few small modifications I want
> to make). Searching hasn’t turned up anything other than
> ly:music-deep-copy... if anyone has a pointer to a template for
> this, I’d be grateful.
OK!
At <URL: http://crism.maden.org/music/swing.ly > is an updated version,
which seems to be working. Comments welcome, as are use and redistribution.
As for the generic shallow copy, the thing I made as a starting point
for this is below, in case anyone else finds it useful for making a
slightly-modified copy of some music.
#(define (my-copy some-music)
(cond
((ly:music? some-music)
(let ((elt (ly:music-property some-music 'element))
(elts (ly:music-property some-music 'elements))
(new-music (ly:music-deep-copy some-music)))
(cond
((not (null? elts))
(ly:music-set-property! new-music 'elements (my-copy elts)))
((not (null? elt))
(ly:music-set-property! new-music 'element (my-copy elt)))
)
new-music))
((list? some-music)
(map my-copy some-music))
(#t
(ly:music-deep-copy some-music))))
~Chris
--
Chris Maden, text nerd <URL: http://crism.maden.org/ >
Surround hate and force it to surrender.
GnuPG fingerprint: DB08 CF6C 2583 7F55 3BE9 A210 4A51 DBAC 5C5C 3D5E