lilypond-user
[Top][All Lists]
Advanced

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

scheme function


From: Gianmaria Lari
Subject: scheme function
Date: Thu, 20 Dec 2018 12:49:46 +0100

Periodically I spend some time on lilypond/scheme hoping to understand a bit more how use them together. This is what I these days.

I tried to write in different way the function nextcount that return a number, as a string, increased by one each time you call it.

%standard version
\version "2.19.82"
#(define nextcount
   (let  ((counter 0))
     (lambda ()
       (set! counter (1+ counter))
       (number->string counter))))

\markup #(nextcount)
\markup #(nextcount)

Alternate version

%alternate version
\version "2.19.82"
nextcount = 
  #(let  ((counter 0))
     (lambda ()
       (set! counter (1+ counter))
       (number->string counter)))

\markup #(nextcount)
\markup #(nextcount)

I would like to know if it is possible to write it using define-scheme-function. This is what I tried that does not compile.

\version "2.19.82"
nextcount = 
  #(define-scheme-function () ()
     (let  ((counter 0))
     (lambda ()
       (set! counter (1+ counter))
       (number->string counter)
       )
     ))
  
\mark \nextcount
\mark \nextcount

Thank you, g.

reply via email to

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