Last active
February 26, 2017 14:27
-
-
Save emres/a364c2584a8b003bb78dfea72099b986 to your computer and use it in GitHub Desktop.
Emacs Lisp function to calculate a test result
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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