• # version 2 pré-béta

    Posté par . En réponse au journal TapTempo en emacs lisp. Évalué à 2.

    Compte tenu des commentaires ci-dessus, voici une version un peu moins approximative du bousin

    (setq t0 nil)
    (setq array (list))
    (defun sum(list) 
     (if (null list)
     0
     (+ 
     (nth 0 list) 
     (sum (rest list))
     ) 
     ) 
     )
    (defun mean(list)
     (/ (sum list) (length list))
     )
    (defun tap ()
     "Record a tap"
     (interactive)
     (setq t1 (float-time()))
     (if t0 (push (- t1 t0) array))
     (if (> (length array) 9)
     (progn
     (message "BPM %S" (* 60 (/ 1. (mean array))))
     (setq array (reverse (cdr (reverse array))))
     ))
     (setq t0 t1))
    (global-set-key "\C-x\C-s" 'tap)