Starting from:
lein new foo
cd foo
Say I have a random JAR file that is not available in any repository:
touch README.md
(defproject foo "1.0.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:dependencies [[org.clojure/clojure "1.3.0"] | |
[org.clojure/clojurescript "0.0-927"]]) |
;; Some example error messages resulting from common mistakes | |
;; using Datomic 0.8.4138 | |
(ns errors | |
(:use [datomic.api :as d :only (db q)])) | |
(def uri "datomic:mem://database") | |
(d/create-database uri) |
;;; data.json 0.1.x compatibility shim | |
;; Loading this file alongside data.json version 0.2.0 adds | |
;; definitions which make it compatible with the public API of | |
;; data.json version 0.1.3. | |
;; Copyright (c) Stuart Sierra, 2012. All rights reserved. The use and | |
;; distribution terms for this software are covered by the Eclipse | |
;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) |
;; Example showing that I cannot convey data from an exception within | |
;; a transaction. | |
(ns example | |
(:require [datomic.api :as d])) ; Datomic Free 0.8.4007 | |
(def uri "datomic:mem:example") | |
(d/create-database uri) |
/* Demonstration of dead-code elimination in the JVM. | |
* | |
* This class demonstrates some of the difficulties of benchmarking | |
* code which may be subject to dead-code elimination by the JVM. | |
* There are two loops, both calling the same function. But only the | |
* second loop actually uses the result of the function. | |
* | |
* When I run this code, I get results like this: | |
* | |
* Dead code: |
;; Demonstration of JVM dead code elimination in Clojure 1.2 and 1.5 | |
;; | |
;; This Clojure script demonstrates some of the effects of dead code | |
;; elimination in the JVM. For unknown reasons, the bytecode produced | |
;; by Clojure 1.2.1 is more susceptible to elimination than the | |
;; bytecode produced by Clojure 1.5.1, making it seem like 1.2.1 is | |
;; faster. But when the code is forced to do real work, the difference | |
;; disappears. | |
;; | |
;; My results with Clojure 1.2.1: |
package example; | |
import java.math.BigInteger; | |
public class Factorial { | |
public static BigInteger factorial(final int n) { | |
BigInteger res = BigInteger.valueOf(1L); //build upresult | |
for (int i = n; i > 1; i--) | |
res = res.multiply(BigInteger.valueOf(i)); | |
return res; |
;; Example implementation of Norvig's Spellchecker in Clojure, | |
;; using core.async | |
;; | |
;; There are probably some bugs in this. | |
;; | |
;; Original problem: https://github.com/ericnormand/spelling-jam | |
;; from Lambda Jam, Chicago, 2013: http://lambdajam.com/ | |
;; | |
;; Clojure core.async introduction: | |
;; http://clojure.com/blog/2013/06/28/clojure-core-async-channels.html |
;; Maze Jam from Lambda Jam 2013, Chicago | |
;; | |
;; by Stuart Sierra, http://stuartsierra.com/ | |
;; | |
;; There are probably bugs in this code. | |
;; | |
;; Copyright (c) 2013 Stuart Sierra | |
;; All rights reserved. | |
;; | |
;; Redistribution and use in source and binary forms, with or without |