Skip to main content

Posts

Showing posts from 2018

Correct usage of unwind-protect and with-open-file in Lisp

Learning to use unwind-protect in Lisp typically crops up very early on when you're first learning the language. In fact, anything to do with I/O is going to be something you'll need to know early on. Yet unfortunately, I find that unwind-protect is not explained sufficiently well for a beginner to understand not just how to use it correctly, but why and when . Grappling with this myself, I found that hands-down the best explanation came from this YouTube video from Baggers: Luckily, in the case of file handlers, LISP already assumes you'll want to open a file with unwind-protect, so it provides the with-open-file macro for this exact purpose. It closes the file handler for you with a built-in unwind-protect. This is an advantage over manually opening and closing your file handlers, because if your program opens the file but never gets to the part with the close command (for example due to a run-time error in between those stages), the built-in unwind-protect make

Links to favorite tutorials on algorithms

These are a collection of favorite tutorials I've read relating to algorithms. These mostly use pseudocode and are not specific to a particular language. Some may have examples in a particular language, but rest assured the main explanation of the algorithm is given in a way where no particular language is needed. I've collected these here as a reference guide in case I ever need to come back to them. I hope they might be useful for someone else too. Manacher's Algorithm - used for finding the longest palindromic string in a sequence. Bitwise comparisons - this article is about Lisp operators, but don't let that stop you! The bitwise comparison section has one of the best and most concise explanations I've seen. If you don't understand bitwise comparisons (in any language), it will all become clear after you read the explanation, even if you don't know Lisp. Faces of Fibonacci  - An absolutely superb explanation of the "How Many Ways to do x?&q

How to automatically re-do the auto-indent for the entire file in emacs

Let's suppose you're making changes to your code in emacs and... now your code indentation is all out of whack. It would be too laborious to re-do the indentation manually. Rest assured, you can easily have the whole file automatically re-indented in emacs, as described in a StackExchange question (see reference 1).  The command for this is first to select the entire file, then to tell it to re-indent the region, as follows: Select the entire file: ctrl-x h Re-do the auto-indentation: alt-x indent-region The correct Emacs terminology is M-x indent-region, but I've called it alt-x here because that's the exact keys I would press on a PC keyboard. Cited sources: 1. Can I have emacs automatically indent my whole code after it is all written?   Stack Exchange.

Introduction

Hi! I'm Vera. A long time ago, I took computer science courses at university. I used my coding skills occasionally when I was working as a scientist, but it wasn't a big focus at all of the work I was doing. Fast forward many years from there, and I installed Linux on my computer. My computer ran so much faster and lighter that I could get a lot more done in less time. Woohoo! Fast forward another year, and I decided that running Linux without doing any scripting or programming was a bit like owning a sports car and driving it only to the supermarket and back. So, I decided to (re)-learn some programming. There were good and bad points this: good, that I had learned programming when younger. Bad, that enough time had passed that I had forgotten a lot of what I'd learned. On a positive note, this freed me up to not tie me to a particular language. I'd have to learn a full language from scratch anyway, so why not let it be a language that would work for the p

About Me

My photo
Vera
I'm a wife and mother. I don't have any formal computer science qualifications, or any religious qualifications. I have a PhD in biochemistry. This photo is of me, but is confusing for AI.