lilypond-user
[Top][All Lists]
Advanced

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

Re: reduce unbound within \context lambda


From: Thomas Morley
Subject: Re: reduce unbound within \context lambda
Date: Sat, 2 Mar 2019 12:11:43 +0100

Am Sa., 2. März 2019 um 03:41 Uhr schrieb Aaron Hill <address@hidden>:
>
> I encountered an unexpected error where reduce is unbound when
> specifying a lambda within a \context block:
>
> %%%%
> \version "2.19.82"
> \layout { \context { \Voice
>    \override NoteHead.color = #(lambda (grob)
>      (display (reduce + 0 '(1 2 3 4))) red)
> } }
> { b'4 }
> %%%%
>
> Compare to the following snippets that work:
>
> %%%%
> \version "2.19.82"
> { \override NoteHead.color = #(lambda (grob)
>      (display (reduce + 0 '(1 2 3 4))) red)
>    b'4 }
> %%%%
> \version "2.19.82"
> #(define (foo grob)
>    (display (reduce + 0 '(1 2 3 4))) red)
> \layout { \context { \Voice
>    \override NoteHead.color = #foo
> } }
> { b'4 }
> %%%%
>
> fold is also unbound, although map works fine.
>
> Am I missing a subtlety here, or is this a bug?
>
>
> -- Aaron Hill

Hi Aaron,

fold, reduce any many other procedures are not part of core-guile, but
of the SRFI-1 module.
Nowadays SRFI-1 is present in every ly-file. Not in \paper and \layout, though.

I don't know how one could change it.
Thus I usually define things outside from layout/paper:

#(define foo (lambda (grob) (display (reduce + 0 '(1 2 3 4))) red))
\layout { \context { \Voice \override NoteHead.color = #foo } }
{ b'4 }

Or quick'n dirty:

#(define reduce reduce)
\layout {
  \context {
    \Voice
    \override NoteHead.color =
      #(lambda (grob) (display (reduce + 0 '(1 2 3 4))) red)
  }
}
{ b'4 }

Cheers,
  Harm



reply via email to

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