lilypond-devel
[Top][All Lists]
Advanced

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

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


From: Mark Polesky
Subject: [PATCH] Re: where to put useful lists in the docs?
Date: Fri, 29 May 2009 01:42:16 -0700 (PDT)

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. I've attached a patch in
case anyone feels this is worth including.

- Mark

;; defines 7 functions:
;; 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_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: 0003-lily-library.scm-math-functions-for-pairs.patch
Description: Binary data


reply via email to

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