lilypond-user
[Top][All Lists]
Advanced

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

Scheme function evluates only once


From: Amir Teymuri
Subject: Scheme function evluates only once
Date: Thu, 23 Jan 2020 19:51:33 +0100
User-agent: mu4e 1.2.0; emacs 25.2.2

Hi,

this is just a nonsense exercise for me to get to know LilyPond better!
I can't figure out why in the following the #(rnd-col) is evaluated only
once and not upon each compilation of my ly file? The first time i
compile this i will get the four colors displayed:

(0.5 0.5 0)
(0.5 0 1.0)
(0.5 0 1.0)
(0 0.5 1.0)

which however doesn't change in next compilations, so that there is no
color change. Can someone explain what am i missing?
Thanks


%%
\version "2.19.83"

#(define (rnd-col) (map (lambda (x) (* x 0.5)) (list (random 3) (random 3) 
(random 3))))

coloredAcc = #(define-music-function () ()
               (newline)
               (display (rnd-col))
               #{              
               \once \override Accidental.color = #(rnd-col)
               #})

\relative c'' {
  \coloredAcc cisis
  \coloredAcc cisis!
  \coloredAcc cisis!
  \coloredAcc cisis!
}
%%
-- 
Amir Teymuri



reply via email to

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