lilypond-user
[Top][All Lists]
Advanced

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

Re: Using Scheme inside Lilypond


From: David Kastrup
Subject: Re: Using Scheme inside Lilypond
Date: Sat, 04 Sep 2021 20:44:32 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Richard Shann <richard@rshann.plus.com> writes:

> Can someone educate me as to why this works:
>
> \markup \path #0.4 #'((moveto 0 0) (lineto -30 50) (lineto -20 80) 
> (closepath))
>
> but this does not:
>
> \markup \path #0.4 #'((moveto 0 0) (lineto -30 (* 2 25)) (lineto -20 80) 
> (closepath))
>
> The difference being I replace 50 with (* 2 25)
>
> (I'm trying to write code that will draw a box round A4 or letter paper
> with just a change of some scaling factors - I can work around it but
> it's distressing not to understand what is going on).

(* 2 25) is a list with 3 elements, the symbol * and the numbers 2 and
25.  In a list quoted with ' Scheme has no incentive to evaluate an
expression.  You could use a quasiquote (a backtick instead of a tick)
to gain the capability of using a comma for temporary evaluation of one
expression, namely

\markup \path #0.4 #`((moveto 0 0) (lineto -30 ,(* 2 25)) (lineto -20 80) 
(closepath))

Numeric constants like 0 and -30 are self-quoting, so putting , before
them does not make a difference.

-- 
David Kastrup



reply via email to

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