Skip to content

Instantly share code, notes, and snippets.

@jturner314
jturner314 / core.clj
Created September 30, 2012 17:37
Removes common indentation from a collection of lines. Written in response to http://jjinux.blogspot.com/2012/09/dart-algorithm-to-unindent-code.html
(ns dedent-text.core
(:use [clojure.string :only [blank?]]))
(defn all-equal?
"Returns the value if all values are equal, otherwise nil."
[& values]
(when (apply = values) (first values)))
(defn count-common-indentation
"Returns length of common indentation of strings."