Skip to main content

Posts

Lisp is a lot more readable than you might first think

At first, Lisp just didn't seem very readable to me. And yes, by this I meant even my own relatively simple code. But as I programmed more and more in Lisp, things became more and more readable. Probably not a surprise, right?! But actually, Lisp is a lot more readable when you are used to it , than a lot of other languages when you are used to them. Let's take a look at how this is, with some examples. Lisp is very readable because of its function-oriented syntax. Lisp statements have the format (function arg1 arg2 ... argN) Thus, any statement must begin with the name of a function. This makes it easy to tell what's going on right away by simply reading left to right within each statement. Also, starting with a function name makes syntax errors extremely easy to spot. For example, let's take a look at this incorrect Lisp code: (12 / 4) Before even getting past the 12, it should be very clear that what's wrong here is that I'm trying to call a f...

If you can shell script, you can Lisp

I've noticed from people's attitudes toward Lisp that many think it is an esoteric and difficult language to learn. Nothing could be further from the truth, but it does depend on what angle you're coming at it from. If you're coming from C, C++, Javascript, or even Python, then yes Lisp does appear impenetrable at first glance. But if you're coming from shell scripting (e.g. Bash or another Linux or Unix shell) - a skill which most programmers have used at some point - then Lisp is going to be very simple and very familiar for you to learn. You may be asking, how is this? Well, I'll demonstrate it with a couple of examples. I'm going to show you a shell command that takes the second column of a space-delimited file test.txt, sorts the resultant data, and shows the second item in the sort. cut -d" " -f2 test.txt | sort | head -2|tail -1 There is absolutely nothing remarkable about this, as you can see. The results of one command are bein...

Funny-looking Linux commands that I actually typed

I thought I'd make an ongoing list here of odd-looking Linux commands that I've typed in the course of my Linux-ing. 1.Looking for information about the date and time command: man date No, computer! I'm not asking you to find me a date! 2. Echoing something as root sudo echo ... Should I have simply completed that command by typing "funky town"? In case you're wondering, there was an 80's song called Funky Town, sung by Pseudo Echo. 3. Looking for information about the find command: man find Yet again, I'm looking desperate for a date.

If all else fails, a good temporary solution to monitor not waking up from timeout in Debian Buster

I recently upgraded from Debian Stretch to Debian Buster (or Debian 9 to Debian 10). I hadn't done anything unusual with my system, so I was expecting a smooth upgrade process. It did work smoothly, with one exception: my monitor simply would not wake up after a screen timeout.   The problem The monitor just refused to wake up after time out, even if I unplugged and replugged its power cord (its own one, separate to the computer). The monitor reported no signal from the computer. However, the computer was actually working fine during this time - the light was on, and the keyboard caps lock key light toggled on and off; a sign that it was indeed working. But with no way to see any of the screen, I simply couldn't do anything to restart the machine except for a hard restart (turning off the computer with the power button and turning it back on). Needless to say, this was not good since I had open unsaved files on my desktop! I couldn't find anything actually helpful o...

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?...

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.