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)?
OpenPGP_signature
Description: OpenPGP digital signature