Thu, 15 Jan 2004 15:55:39 +0100, Han-Wen a dit : 

 >> \note       (The syntax for this is really bad!  Why not just \note 2. <dir>,
 >> and let the computer compute logarithms and count dots?)

 > I added a TODO. If anyone feels challenged, feel free to change. My
 > suggestion:

 >      \note #"2."

This one might be used to parse the duration argument:

(use-modules (ice-9 optargs)
             (ice-9 regex))

(defmacro*-public aif (test-form then-form #:optional else-form)
  "Anaphoric IF. Introduce a binding for `it'"
  `(let ((it ,test-form))
     (if it ,then-form ,else-form)))

(define-public log2 
  (let ((divisor (log 2)))
    (lambda (z) (inexact->exact (/ (log z) divisor)))))

(define (parse-simple-duration duration-string)
  "Parse the `duration-string', eg ''4..'', and return a (log dots) list."
  (aif (regexp-exec (make-regexp "([0-9]+)(\\.*)") duration-string)
       (list (log2 (string->number (match:substring it 1)))
             (aif (match:substring it 2) (string-length it) 0))
       (error "This is not a valid duration string:" duration-string)))


guile> (parse-simple-duration "8..")
(3 2)

nicolas



_______________________________________________
Lilypond-user mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/lilypond-user

Reply via email to