RSS

HOW-TO: Poor Man’s Quiz Scorer in Emacs Lisp

26 Feb

Sometimes it’s about small data.

Recently I’ve been studying a topic using a book, and at the end of each chapter there are quizzes of 20-25 questions. My method was to open a text buffer in Emacs, and vertically note down the question number, my answers, and after finishing this, go to the correct answer list, and mark correct answers with Y, and wrong ones with N:

Y 1- A,B,C
Y 2- C
N 3- D
N 4- C
Y 5- A
Y 6- B,C,D
Y 7- B

That was all fine, but I found myself counting the number of correct answers, and calculate my score in terms of percentage manually. I could of course quickly run the `M-x count-matches` (or `how-many`) to see how many correct / wrong answers I had, but doing this more than a few tests seemed to become tedious. Therefore, Emacs Lisp to the rescue!

With this simple Emacs Lisp function, assigned to F12 function key, I can now simply hit F12 and see my score percentage in Emacs:

“Your test score percentage: 71.42857142857143”

There are of course alternative methods to solve this straightforward problem, e.g. you can run some shell scripts on your Emacs (or VIM) buffer, or on a simple text file. But I like this solution being self-contained in Emacs, as well as the fact that it’ll continue to run as intended 30 years from now, in a newer Emacs version probably. This, and the fact that, my preferred tool for dealing with textual data gives me the flexibility to program it any way I want. It might have its drawbacks, it might be showing its age in its architecture, there are newer, shiny tools, there are specialized IDEs for various programming languages I use, but all of these notwithstanding, I still like to think it’s a beautiful thing that an editor released when I was born, that helped me with many tasks for decades, will still be with me for decades to come.

Advertisements
 
Leave a comment

Posted by on February 26, 2017 in Programlama, Emacs

 

Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: