The Fantastic SUBST Function (part 4)

This post is the final part of a series of articles about LISP, a function called SUBST, Clojure, and other interesting stuff. You probably want to read the previous posts before continuing with this. Part 1: Introducing LISP Part 2: Walking through SUBST Part 3: Clojure version of SUBST In part 1 of this series, [...]

Tags: , , , ,

The Fantastic SUBST Function (part 3)

This post is part of a series of articles about LISP, a function called SUBST, Clojure, and other interesting stuff. You may want to read the previous posts before continuing with this post. Part 1: Introducing LISP Part 2: Walking through SUBST In part 1 of this series, we learned about the nine special forms [...]

Tags: , ,

The Fantastic SUBST Function (part 2)

This post is part of a series of articles about LISP, a function called SUBST, Clojure, and other interesting stuff. You may want to read the previous post before continuing with this post. Part 1: Introducing LISP In part 1 of this series, we learned about the nine special forms of LISP, the building blocks [...]

Tags: , ,

The Fantastic SUBST Function (part 1)

When John McCarthy in 1960 wrote his famous paper on the programming language LISP, he used a particular function to illustrate what you could do with the language. The language consisted of only nine “special forms”, primitive building blocks by which any computable function could be created. The function was called SUBST, and it included [...]

Tags: , ,

Getting ShowOff source code high-lighting for Clojure

ShowOff is a presentation software where you create your slides by writing simple text files containing markdown formatting. Styling is done using CSS. The slides are served by a web server and can be displayed in a web browser. With a simple command, a presentation can be deployed on Heroku for everyone to see. ShowOff [...]

Tags:

Clojure third language officially supported on Heroku

According to this blog entry on Heroku, Clojure becomes the third language officially supported on the Cedar stack, after Ruby and Node.js. They write: – “Clojure combines the expressiveness of Lisp, the agility of a dynamic language, the performance of a compiled language, and the wide applicability of the JVM in a robust, production-ready package. [...]

Tags: , , ,

Deploying a Clojure web app on Heroku

Heroku is a cloud application platform for Ruby/Rails and Node.js. However, the Cedar stack on Heroku makes it possible to deploy other types of applications. In this blog entry, I will first describe how to write a simple Clojure web app using the Ring library and the build tool Leiningen. Then I will show how to deploy this Clojure web app on Heroku, using nothing but Git. I will make a change and see how to deploy that. I will also show how to easily roll back to a previous release.

Tags: , , , , ,

Numerical Integration (With Precision)

In a previous blog entry, I explained the higher-order function sum and how to use the Substitution Model to follow the execution of a function. In this entry, I will use the sum function to perform numerical integration, and in the process run into some pitfalls of Java’s BigDecimal. I will show how the language Clojure provides an elegant solution to the “exact quotient cannot be represented” problem of BigDecimal.

Tags: , , , , ,

The Substitution Model: A Tool For Understanding Recursion

Section 1.3 in Structure and Interpretation of Computer Programs is about Formulating Abstractions with Higher-Order Procedures. As an example, the authors use three simple sums: a sum of an integer range a sum of the cubes of an integer range a sum of a series that converges to π/8 The purpose is to highlight what [...]

dbg: A Cool Little Clojure Macro

Here’s the development of a tiny little macro that is actually pretty useful. The post is quite verbose, because I explain a lot. I want a debug function that first prints the “quoted” (unevaluated) code and then what it evaluates to, so I can write something like this: user> (dbg (+ 1 2)) dbg: (+ [...]

Tags: , ,

The country that nearly drove me crazy

I just upgraded my OpenLDAP to 2.4.21 and suddenly I couldn’t load an LDIF that we in Spring LDAP have used successfully for years. % ldapadd -Dcn=Manager,dc=jayway,dc=se -wsomepwd -f /tmp/t.ldif adding new entry “ou=groups,dc=jayway,dc=se” adding new entry “c=Sweden,dc=jayway,dc=se” ldap_add: Invalid DN syntax (34) After some time of swearing and random changes, I managed to find [...]

Tags:

The Golden Ratio

Also known as the “Divine Quotient”, the Golden Ratio was given an almost magical meaning during the renaissance, but it’s actually much older than that. Leonardo DaVinci used it. Euclid used it. It was supposedly discovered by Pythagoras. So, what is it? It’s very simple. Take a length and divide it into two parts: a [...]

Tags: , , , ,

The Power of Unit Testing

The purpose of Unit Testing is to verify for the developer that a software unit does what it is supposed to and is fit for use. The confidence that the developer gets, gives the developer courage to do other useful practices like Refactoring. Unit testing is often used to test complex units with one or [...]

Tags: ,

Upgrading Groovy to 1.6.2 Fails on Mac

When I tried to upgrade Groovy from 1.6.1 to 1.6.2 using MacPorts, it failed with an OutOfMemoryError. I managed to get it to build using some manual fixing in the build file. I’ll explain what I did in this blog. This was the result that I got: $ sudo port upgrade groovy —> Building groovy [...]

Tags: , , , , ,

Always Use Parenthesis in Groovy Builders

I recently ran into an interesting Groovy feature when demonstrating the strengths of the MarkupBuilder. As you probably know, parenthesis in a Groovy method call are optional, unless it’s a no-args call. In that case the parenthesis are needed in order to distinguish the call from a property. However, leaving out parenthesis in a Builder is asking for trouble. I’ll show you why.

Tags: , , , , ,