lilypond-devel
[Top][All Lists]
Advanced

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

Re: [Lilypond-auto] Issue 2607 in lilypond: Patch: Allow immediate Schem


From: David Kastrup
Subject: Re: [Lilypond-auto] Issue 2607 in lilypond: Patch: Allow immediate Scheme expressions to take multiple values
Date: Fri, 22 Jun 2012 09:25:58 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

Werner LEMBERG <address@hidden> writes:

> I find the above much too dense.  It introduces three different pseudo
> operators in one rush.  While tightly related, it should be done step
> by step.  So this is a criticism of the R6RS docs (being a standard to
> be read by Scheme experts), not LilyPond.  However, a casual reader
> not so fluent in Scheme will tear one's hair if she gets confronted
> with your $@ form.
>
> Perhaps it's a bit redundant, but I think that it would help many
> readers if some Scheme basics are added to the documentation of $@
> *directly*, demonstrating the unquote-splicing mechanism in very basic
> examples.

Problem is that the Scheme tutorial has not really reached the level
when they get first mentioned where one can actually make a useful
example.  I get back to them later.

It's one of those cases where I am stuck coming up with something
better.  If I break down the example I listed before, here are a few
useful ways of applying it:

\score
{
  \displayLilyMusic
  {  $@(map!
       (lambda (p d) #{ < address@hidden >address@hidden #})
; this $@ produces elements for a sequential music list via map!.  Each
; element is constructed from p, a list of pitches making up a chord,
; and from d, which is a list first containing a duration followed by
; _optional_ articulations, so address@hidden actually can return several 
tokens of
; _different_ type.
;
; The following form constructs the list of pitch lists for use in p
       (let loop
           ((c (map!
                (lambda (i)
                  (let ((p (+ 15 (* 9 (quotient i 5)) (* i -2))))
                    (ly:make-pitch (quotient p 7) (remainder p 7) 0)))
                (iota 38)))
            (l '()))
         (if (null? (cddddr c))
             (let ((fin (cadr l)))
               (reverse! l (list fin)))
             (loop (cdr c) (cons (list-head c 5) l))))
; The following form constructs an (end-less) list of lists containing
; a duration and maybe articulations.
       (apply
        circular-list
        (map!
          (lambda (m) (cons (ly:music-property m 'duration)
                            (ly:music-property m 'articulations)))
          (extract-typed-music
             #{ s4.~ s~ s4~ s2~ s2 #}
             'skip-event))))
    <c' e' g' a' c''>1 \bar "|."
  }
  \midi { \tempo 4 = 220 }
  \layout { }
}

That's a reasonably nice snippet (except that the output looks
horrendous).  But not really at the level of the Scheme tutorial.

-- 
David Kastrup




reply via email to

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