Skip to content

Instantly share code, notes, and snippets.

(defproject clj-blog "0.0.1"
:description "Clojure Blog App"
:dependencies [[org.clojure/clojure "1.2.0-master-SNAPSHOT"]
[org.clojure/clojure-contrib "1.2.0-SNAPSHOT"]
[org.clojure/clojure-http-client "1.0.0-SNAPSHOT"]
[compojure "0.4.0-RC3"]
[enlive "1.0.0-SNAPSHOT"]
[org.markdownj/markdownj-core "0.4-SNAPSHOT"]
[org.clojars.the-kenny/clojure-couchdb "0.1.3"]]
:dev-dependencies [[lein-clojars "0.5.0-SNAPSHOT"]
(defn compress [l]
(let [sum-up (fn [l e]
(if (= (last (drop-last l)) e)
(conj (vec (drop-last l)) (inc (last l)))
(conj l e 1)))]
(reduce sum-up [] l)))
(ns sample.grep
"A simple complete Clojure program."
(:use [clojure.contrib.io :only [read-lines]])
(:gen-class))
;; same as clojure.contrib.seq/indexed, just to show how to do it
(defn numbered-lines [lines]
(map vector (iterate inc 0) lines))
(defn grep-in-file [pattern file]
(ns sample.grep
"A simple complete Clojure program."
(:use [clojure.contrib.io :only [read-lines]])
(:gen-class))
(defn numbered-lines [lines]
(map vector (iterate inc 0) lines))
(defn grep-in-file [pattern file]
{file (filter #(re-find pattern (second %)) (numbered-lines (read-lines file)))})
(ns sample.grep
"A simple complete Clojure program."
(:use [clojure.contrib.io :only [read-lines]])
(:gen-class))
(defn make-counter [initial-value]
(let [current-value (atom initial-value)]
(fn []
(swap! current-value inc))))