Skip to content

Instantly share code, notes, and snippets.

@emres
Last active February 26, 2017 14:27
Show Gist options
  • Save emres/a364c2584a8b003bb78dfea72099b986 to your computer and use it in GitHub Desktop.
Save emres/a364c2584a8b003bb78dfea72099b986 to your computer and use it in GitHub Desktop.
Emacs Lisp function to calculate a test result
(defun calculate-test-result ()
"Calculate test result.
This function assumes that you use Y for correct answers, and N for wrong ones."
(interactive)
(let* ((correct (how-many "Y" 1))
(wrong (how-many "N" 1))
(total (+ correct wrong))
(percentage (/ (* 100.0 correct)
total)))
(message (concat "Your test score percentage: "
(number-to-string percentage)))))
(global-set-key (kbd "<f12>") 'calculate-test-result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment