lilypond-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Re: where to put useful lists in the docs?


From: Mark Polesky
Subject: Re: [PATCH] Re: where to put useful lists in the docs?
Date: Sat, 30 May 2009 01:20:28 -0700 (PDT)




----- Original Message ----
> From: Mark Polesky <address@hidden>
> To: Mark Polesky <address@hidden>; Neil Puttock <address@hidden>
> Cc: lilypond-devel <address@hidden>
> Sent: Friday, May 29, 2009 1:42:16 AM
> Subject: [PATCH] Re: where to put useful lists in the docs?
> 
> Mark Polesky wrote:
> > ... I've ended up writing quite a few of
> > these functions without knowing that they were all here.
> 
> Here's another useful set of procedures that is not in
> lily-library.scm. These functions make quick work of calculating
> offsets, extents, bounding-boxes, etc. 

Here's a new patch that also incorporates conditionals.

;; defines 14 functions:
;; pair_+    pair_-     pair_*     pair_/
;; pair_=    pair_<     pair_>     pair_<=    pair_>=
;; pair_gcd  pair_lcm   pair_min   pair_max   pair_average.
;; eg. (pair_+ '(1 . 1) '(2 . 3) '(5 . 8)) ==> (8 . 12)
;;     (pair_<= '(1 . 8) '(1 . 5) '(2 . 3)) ==> (#t . #f)
;;     (pair_min '(1 . 8) '(1 . 5) '(2 . 3)) ==> (1 . 3)
(map primitive-eval
 (map
  (lambda (f)
   `(define-public
      (,(symbol-append 'pair_ f) . pairs)
      (apply (lambda (f . pairs)
               ((lambda (lst) (cons (car lst) (cadr lst)))
                (primitive-eval
                 (append `(map ,f)
                          (map (lambda (x) `(list ,(car x) ,(cdr x)))
                               pairs)))))
             ,f pairs)))
 '(+ - * / = < > <= >= gcd lcm min max average)))



      

Attachment: 0001-lily-library.scm-math-functions-for-pairs.patch
Description: Binary data


reply via email to

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