Using Pythons matplotlib

I had a look at the python 2D plotting library matplotlib. For more information about this library, you might want to have a look at the corresponding Wikipedia article. I’m looking for a way to make simple plots from x,y value pairs and it […]

common-lisp.net to use gitlab

CMUCL announcement: “common-lisp.net has been slowing transitioning services to use gitlab.  The transition is pretty much done, and cmucl is now officially at https://gitlab.common-lisp.net/cmucl/cmucl. The ticket system and wiki is still using https://trac.common-lisp.net/cmucl, but we hope to migrate that to gitlab as well.”

Thoughts on creating objects in Lisp

If you work with classes in Lisp, you might want to hide the details of creating an object of a class. This practise is generally known as the factory method pattern. I’ll show a very simple example. Let’s assume, you have defined the following […]

Defining Lisp classes in packages

In Lisp, when you define classes in packages, you have to remember that you have to explicitly export the accessors too. For example, you define the following package with a class inside. (defpackage :mhn-foo   (:use :common-lisp)   (:export #:fooclass)) (in-package :mhn-foo) (defclass fooclass […]

Making decisions

It is interesting to have a look at how you make decisions in different programming languages. In Python, for example, the code is straightforward. >>> if 1 < 2: …     print ‘smaller’ … else: …     print ‘bigger’ …  smaller >>>  […]

Serializing Lisp lists

In Lisp, it is very easy to serialize and deserialize lists into files. You can use the macros with-open-file and print for this. Using macro with-open-file makes sure that the file is closed automatically even in case of failures. The print macro prints lists […]

JSON in Python and Common Lisp

Both, Python and Common Lisp have libraries for writing and reading JSON format. JSON can be used as an alternative to XML, when not only machines will read the data. XML can be hard to read when you have more tags than data. JSON […]

Regular Expressions in Lisp

There are various different regular expression libraries available for Lisp. A nice overview can be found at CLiki. I had a look at the Portable Perl-compatible regular expressions for Common Lisp (CL-PPCRE). Installation is very easy using Quicklisp. After installation you can add the library […]

Regular Expressions: Groups

In Python, you can write the following, to capture groups of characters with regular expressions. >>> import re >>> print(“Match is ‘” … + re.search(‘\\s([a-z]+)\\s’, … ‘My text string.’).group(1) + “‘”) Match is ‘text’ >>>  This is quite straightforward. In C#, you can write […]