This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/scratch/clojurescript$ ./script/bootstrap | |
Fetching Clojure... | |
Copying clojure-1.3.0/clojure-1.3.0.jar to lib/clojure.jar... | |
Cleaning up Clojure directory... | |
Cleaning up Clojure archive... | |
Fetching Google Closure library... | |
Cleaning up Google Closure library archive... | |
Fetching Google Closure compiler... | |
Cleaning up Google Closure compiler archive... | |
Building lib/goog.jar... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn- ipred [[k v]] | |
(pred/like k v)) | |
(defn- partial-pred [m] | |
"Turn a map into a predicate format understood by cql. IE {:a 1 :b 2} --> (pred/and* (pred/=* :a 1) (pred/=* :b 2))" | |
(apply pred/and* (map ipred m))) | |
(defprotocol MapFindable | |
"A protocol for clojureQL searchable things that can be found using a map interface" | |
(find [this search-map])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns relation.test.relation | |
(:require [relation.relation :as rel] | |
[relation.database :as db] | |
[clojureql.core :as cql]) | |
(:use [clojure.test])) | |
(defmacro my-macro | |
[x] | |
`~(reverse x)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<build> | |
<plugins> | |
<plugin> | |
<groupId>com.theoryinpractise</groupId> | |
<artifactId>clojure-maven-plugin</artifactId> | |
<version>1.3.2</version> | |
<executions> | |
<execution> | |
<id>test-clojure</id> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns bookkeeper.database | |
(:require [clojure.java.jdbc :as sql] | |
[clj-time.format :as f])) | |
(def db {:classname "com.mysql.jdbc.Driver" | |
:subprotocol "mysql" | |
:subname "//database-server:3306/database" | |
:user "user" | |
:password "password"}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'package) | |
(add-to-list 'package-archives | |
'("marmalade" . "http://marmalade-repo.org/packages/")) | |
(package-initialize) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(eval-after-load 'clojure-mode | |
'(progn | |
(require 'paredit) | |
(defun clojure-paredit-hook () (paredit-mode +1)) | |
(add-hook 'clojure-mode-hook 'clojure-paredit-hook) | |
(define-key clojure-mode-map "{" 'paredit-open-brace) | |
(define-key clojure-mode-map "}" 'paredit-close-brace))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defproject com.evocomputing/rincanter | |
"1.0.0-SNAPSHOT" | |
:description "Clojure/R integration using rosuda JRIEngine" | |
:dependencies [[org.clojure/clojure "1.2.0"] | |
[org.clojure/clojure-contrib "1.2.0"] | |
[incanter "1.2.3"]] | |
:native-dependencies [[jriengine "0.8.4"]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Introduction</h1> | |
This is a brief post about how laziness can be used to construct a step-wise quicksort, or somebody gets excited about laziness. | |
<P> | |
Laziness is not something I'd come across before Clojure, and I've been repeatedly bitten by forgetting about it. So it was a real pleasure the other day to see the laziness revealed in some code, and for once not have this as the result of protracted debugging. I was so taken aback that I'm sharing the experience. | |
<h1>Quicksort</h1> | |
<h2>The Algo</h2> | |
We all know the <a href="http://en.wikipedia.org/wiki/Quicksort">algorithm</a>, and <a href="http://bilfp.wikidot.com/why-functional-programming-matters">here's</a> a pretty Clojure implementation: | |
<pre class="brush:Clojure"> | |
(defn qsort [[pivot & tail]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(declare *connection*) | |
(defn it-works [] | |
(binding [*connection* "hello, world"] | |
(prn *connection*))) | |
(defn it-works-now [] | |
(binding [*connection* "hello, world"] | |
(map | |
(bound-fn [_] (prn *connection*)) |