lilypond-devel
[Top][All Lists]
Advanced

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

Re: procedure to check equality of list-elements


From: Jean Abou Samra
Subject: Re: procedure to check equality of list-elements
Date: Sun, 6 Nov 2022 13:07:33 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1

Le 06/11/2022 à 13:03, Thomas Morley a écrit :
Hi,

in !1701 `ly:beam::calc-knee' checks whether all list-elements are equal.
Basically doing (apply eqv? <number-list>).
Tbh, I don't understand why it works...


eqv? has no problem working on more than two elements.

scheme@(guile-user)> (eqv? 1 1)
$1 = #t
scheme@(guile-user)> (eqv? 1 2)
$2 = #f
scheme@(guile-user)> (eqv? 1 1 1)
$3 = #t
scheme@(guile-user)> (eqv? 1 1 2)
$4 = #f
scheme@(guile-user)> (eqv? 1 1 1 1)
$5 = #t
scheme@(guile-user)> (eqv? 1 2 3 4)
$6 = #f
scheme@(guile-user)> (eqv?)
$7 = #t



This is similar to how in other languages you have to
repeat the + operator (a+b+c+d) whereas in Scheme you
can do (+ a b c d).



Though, the need to check a list for all list-elements are equal
happened to me not only once.
Thus, would it be acceptable to add something like:

(define* (equal-list-elts? list #:optional (proc eq?))
   (apply proc list))

to lily-library.scm?



What would be the point? Do you dislike (apply proc lst)?

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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