Lisp and Mathematics

I’ve written many times about Atebey Kaygun’s blog and his wonderful exploration of mathematics through Lisp. Robert Smith over at symbo1ics has a nice video on using Common Lisp for mathematics. It’s a long video that explores how Lisp is a superior platform for doing mathematics.

I’ve found this to be true in my own work. I like to experiment with cryptographic algorithms and almost always this involves bignum arithmetic. In Lisp you don’t have to think about this—it just happens automatically. If you’re writing in C it’s a nightmare. As Smith says, the code looks like assembly language where every arithmetic operation appears on a separate line.

It’s not just the numerical tower, though. Watch the video to see some of the other benefits that Lisp has to offer in Mathematical programming. Smith also covers some of the short comings of Lisp in this area.

The video is over an hour and 45 minutes so you’ll need to schedule some time to watch it. I enjoyed the video and if you like Mathematics and Lisp, you probably will too.

Posted in General | Tagged | Leave a comment

Scripting with Emacs

Sebastian Wiesner over at lunarsite has an excellent tutorial on scripting with Emacs. By “scripting with Emacs” he means we’d like to have a shell script containing some Elisp or a reference to a file containing some Elisp into which we can pass some arguments and have the script call Emacs and execute the Elisp with the arguments. It turns out to be trickier than you might think.

We all know about --script and --batch but there are a lot of corner cases that Wiesner explores. The problem, as he explains, is that Emacs is really an editor and attempts to use it as a general scripting language brings difficulties.

If you’re interested at all in scripting with Emacs, Wiesner’s post is a must read. Even if you’re not interested right now, it’s worth taking a look and bookmarking it for later.

Posted in Programming | Tagged , , | Leave a comment

The info-display-manual Command

The prolific Bozhidar Batsov has another nice Emacs tip. If you want to want to look up an Info manual and know its name you can use the info-display-manual command to go right to it. This probably doesn’t save much time unless you give it a convenient key binding—Batsov recommends 【Ctrl+i】 but you can use whatever makes sense for your configuration. If you access the Info manuals from Emacs regularly, you should head over to Emacs Redux and check out his post.

Posted in General | Tagged | 1 Comment

Emacs Rocks! Episode 15

After 19 months, Magnar Sveen is back with episode 15 of Emacs Rocks!. Emacsers everywhere will rejoice, I’m sure.

This episode is a demonstration of Pavel Kurnosov’s restclient package. It’s a very handy and simple way of exercising HTTP REST webservices. You can get results in text, JSON, XML, or even images. Watch Sveen’s excellent video to get an idea of what you can do.

Posted in General | Tagged | 2 Comments

Lisp Weenies

What’s wrong with the picture in A Cat Cons, my post from yesterday?

Posted in Programming | Tagged , | 2 Comments

The Longest Common Subsequence

Atabey Kaygun has another great post. This time it deals with finding the longest common subsequence of two sequences. First Atabey describes a simple algorithm for finding the longest common subsequence and then implements it in Common Lisp. The surprise is that it took over 4.4 seconds to calculate the longest common subsequence of the two sequences

(6 9 5 1 3 5 4 0 7 4 9 1 1 3)
(7 10 2 8 9 11 1 10 7 9 11 8 10 0 5 6 11)

The algorithm is recursive but this seems like a lot of time for a such short input. What’s going on?

Atabey gives us the answer. He memoizes his code using the code that I discussed previously. When he does this—simply using mem-defun instead to defun to define his function—the time drops to 0.006 seconds. Take a look at his lcs function and see if this surprises you. It did me. You have to think carefully about what’s going on to see why the memoization made any difference at all let alone such a dramatic one. Atabey’s post is definitely worth a read.

Speaking of memoization, if you missed PuercoPop’s comment to my previous post on the subject, be sure to follow his link to Fare Rideau’s beautiful article exploring Common Lisp implementations of the Fibonacci sequence. You’ll be glad you did.

Posted in Programming | Tagged , | Leave a comment

A Cat Cons

Via Magnar Sveen we have this offering from Dmitry Ignatiev

Posted in General | Tagged , , | Leave a comment

Sharp Quote and Emacs

Artur Malabarba has some good advice on sharp quoting Elisp functions. It’s common for Elisp programmers to use a single quote (i.e the quote form) to mark functions. Malabarba explains why it’s better practice to use #' (i.e. the function form) to indicate a function.

This is a great post (as usual for Malabarba) and all Elisp programmers should read it.

Posted in Programming | Tagged , | Leave a comment

Amazon and the Publishers

Over at Vox.com, Matthew Yglesias has a provocative article on the contretemps between Amazon and the publishing industry and with Hachette in particular. It’s mainly been portrayed in the press as an argument over prices but Yglesias says that’s just a side show.

The truth, he says, is that the publishing industry is dying and its current battles with Amazon won’t alter that fact regardless of the final outcome. The reason for the industry’s imminent death is that it no longer provides any benefit.

That wasn’t always true, of course. It used to be that books had to be typeset, printed, bound, and shipped to retailers. It was virtually impossible for authors to do these things on their own so the publishers provided a necessary service. With the advent of ebooks, those services are no longer required. Software to take an author’s manuscript and produce an ebook is widely available, often for free. And, of course, printing, binding, and shipping are not required at all.

What about marketing, then? Surely one of the key services a publisher provides the author is marketing. Yglesias says that, in fact, the publishers are terrible at marketing. He says that the current argument between Amazon and Hachette proves this. If Hachette actually was good at marketing they could simply market their books to other vendors and directly to the public at large.

You may or may not agree with Yglesias but one thing he says is certainly true: the fight between Amazon and Hachette really boils down to who gets to keep the extra profits flowing from the fact that producing another copy of an ebook is essentially cost free. Amazon says they should be used to reduce the price. Hachette wants to keep them. Inasmuch as Hachette and the other publishers have been claiming for years that ebooks cost about the same as physical books to produce, I’m not inclined to accept their arguments.

Yglesias has other arguments supporting his thesis so you should definitely go read what he has to say. It’s a fascinating idea you don’t hear very often—at least in public.

Posted in General | Tagged | Leave a comment

Being Smart

Matt Blaze has a realization that probably applies to us all. I know it applies to me.

(via Jean-Philippe Paradis)

Posted in General | Tagged | Leave a comment