[oops, follow-up mistake, back to devel] Fri, 16 Jan 2004 19:48:19 +0100, Han-Wen a dit :
> [EMAIL PROTECTED] writes: >> >> 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: > Great! Can you add code to do handle breve, longa and maxima too? Thanks! What would the duration string look like in these cases? "longa" "breve.." "maxima."? (use-modules (ice-9 optargs) (ice-9 regex)) (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..'' or ''breve.'', and return a (log dots) list." (let ((match (regexp-exec (make-regexp "(breve|longa|maxima|[0-9]+)(\\.*)") duration-string))) (if (and match (string=? duration-string (match:substring match 0))) (let ((len (match:substring match 1)) (dots (match:substring match 2))) (list (cond ((string=? len "breve") -1) ((string=? len "longa") -2) ((string=? len "maxima") -3) (else (log2 (string->number len)))) (if dots (string-length dots) 0))) (error "This is not a valid duration string:" duration-string)))) nicolas _______________________________________________ Lilypond-devel mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/lilypond-devel