This is just a quicky that might be useful to others, too. The following function unzips the input to the output. Update: As Ben pointed out, tis will only work correctly for gzipped text files encoded in UTF-8 as input (ASCII, ISO-5589-1 will also be fine). (ns foobar (:require [clojure.java.io :as io])) (defn gunzip [fi [...]
Posts Tagged ‘clojure’
Using Clojure’s core.logic with custom data structures
Posted: January 6, 2012 in Clojure, LispTags: clojure, core.logic
With a lot of help from Ambrose, I managed to make Clojure’s core.logic library work with my custom Java data structures. In this posting, I’ll explain the code. I assume that you are already familiar with Clojure in general, and you know core.logic and relational programming at least from a user’s point of view. Ok, [...]
In my last post, I’ve introduced the defmacro! macro, which is just like defmacro, except that it guarantees that all of the arguments are evaluated once only. However, in contrast to Doug Hoyte’s defmacro! he introduced in Let over Lambda, my macro expanded into a normal defmacro form that expanded into a form where all [...]
When programming macros, it’s often desired to have its arguments evaluated only once. Let’s have a look at a simple example: user> (defmacro square [x] `(* ~x ~x)) #’user/square user> (square 5) 25 At a first glance, it seems to work. But see what happens here: user> (def c (let [a (atom 4)] #(swap! a [...]