[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Define markup with iteration
From: |
Paul Morris |
Subject: |
Re: Define markup with iteration |
Date: |
Tue, 14 Apr 2015 08:52:11 -0700 (MST) |
Schneidy wrote
> Unfortunately I still cannot get anything.
> So, if I follow your instructions here's what I get:
>
> #(define-markup-command (staff-lines-it layout props n pad long) (number?
> number? number?)
> (interpret-markup layout props
> (if (= n 0)
> (markup (#:path 0.15 `((moveto 0 ,(* pad 0))(lineto ,long
> ,(* pad 0)))))
> (markup
> (#:combine
> (#:path 0.15
> (fold
> (lambda(i,prev)
> (cons
> (moveto 0 (* pad i))
> (cons
> (lineto long (* pad i))
> prev)))
> '()
> (reverse (iota (1+ n))))
> )))
> )))
>
> \markup\staff-lines-it #5 #1 #10
>
> And does not compile.
> What am I missing?
I made some changes and the version below appears to work.
- (i,prev) --> (i prev)
- no need for (#:combine
- quasi-quoting and unquoting in the lambda in the fold
- move path construction so you can display the path for debugging
Cheers,
-Paul
%%%%%%%%%%%%%%%%%%%%%
\version "2.18.2"
#(define-markup-command (staff-lines-it layout props n pad long)
(number? number? number?)
(define the-path
(fold
(lambda (i prev)
(cons
`(moveto 0 ,(* pad i))
(cons
`(lineto ,long ,(* pad i))
prev)))
'()
(reverse (iota (1+ n)))))
;; (display the-path)
(interpret-markup layout props
(if (= n 0)
(markup (#:path 0.15 `((moveto 0 ,(* pad 0))(lineto ,long ,(*
pad 0)))))
(markup
(#:path 0.15 the-path )))))
\markup\staff-lines-it #5 #1 #100
--
View this message in context:
http://lilypond.1069038.n5.nabble.com/Define-markup-with-iteration-tp174500p174511.html
Sent from the User mailing list archive at Nabble.com.