Ciao Harm, Andrew, Aaron and David,
this is what I have been able to do adapting Harm code:
\version "2.21.0"
foo =
#(let ((x '(1)))
(define-scheme-function (arg)(symbol?)
(case arg
((incNumber) (set! x (append (drop-right x 1) (list (1+ (last x))))))
((unindent) (drop-right! x 1))
((indent) (append! x '(1)))
((reset) (set! x '(1))))
(object->string x)))
\markup \foo #'start %output: 1
\markup \foo #'indent %output: 1 1
\markup \foo #'incNumber %output: 1 2
\markup \foo #'incNumber %output: 1 3
\markup \foo #'incNumber %output: 1 4
\void \foo #'unindent
\markup \foo #'incNumber %output: 2
(the output formatting is not correct, just an example).
>From my side it can be improved to make it more user friendly (maybe
checking "start" etc.) but they are details.
I will spend some time to understand if the definition of x outside the
define-scheme-function is the correct way to do (is this is a closure?)
* * *
I read all the technical discussion, interesting but definitely too far
from what I understand at the moment of the language.
* * *
I didn't yet check the new code you sent Harm,
[harm code]
#(define (increase lst idx)
(if (and (positive? idx) (<= idx (length lst)))
(let ((tmp-lst (take-right lst idx)))
(cons (1+ (car tmp-lst)) (cdr tmp-lst)))
(begin
(ly:warning
"idx ~a is not positive or list ~a does not contain enough elements,
ignoring"
idx lst)
lst)))
[.....]
... but I'm doing it today! Thanks a lot!!!
Ciao, gianmaria
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user