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
Hello world. |
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 pivot | |
([data kf vf](pivot data kf vf +)) | |
([data kf vf reduct-fn] | |
(apply merge-with reduct-fn | |
(map #(apply hash-map ((proj kf vf) %)) | |
data)))) |
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 chain-comp | |
"This takes a list of comparator functions, and chains them together. | |
It returns another comparator. It behaves similar to comp, in that | |
comparisons are done right to left." | |
[& comps] | |
(fn [a b] | |
(loop [remaining-comps (reverse comps)] | |
(let [iter-comp (first remaining-comps) | |
iter-result (iter-comp a b)] | |
(if (and (zero? iter-result) (next remaining-comps)) |
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 apply-map | |
"This works like apply, gmabut for keyword arguments in a map." | |
[f & args] | |
(let [pos-args (butlast args) | |
a-map (last args) | |
applied-args (concat | |
(if pos-args pos-args []) | |
(cond | |
(nil? a-map) [] | |
(map? a-map) (reduce concat a-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
(defn str-drop-while | |
[pred coll] | |
(apply str (drop-while pred coll))) | |
(defn str-take-while | |
[pred coll] | |
(apply str (take-while pred coll))) |
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
;These tests are how Sean Devlin proposes that this function should behave. | |
(deftest test-flatten-proposed | |
(are [expected nested-val] (= (flatten nested-val) expected) | |
;simple literals | |
nil nil | |
1 1 | |
'foo 'foo | |
:keyword :keyword | |
1/2 1/2 | |
#"[\r\n]" #"[\r\n]" |
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 vreplace | |
([s p r] (replace s p r)) | |
([s p r & more] | |
(let [pair (take 2 more) | |
next-p (first pair) | |
next-r (second pair) | |
remaining (drop 2 more)] | |
(if next-r | |
(replace (replace s next-p next-r remaining) p r) | |
(replace s p r))))) |
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
import java.util.regex.*; | |
import clojure.lang.Ifn; | |
/**Delagates the appropraite methods to the Pattern Object | |
However, it adds IFn ability as well. | |
*/ | |
public class ClojurePattern implements IFn, Serializable{ | |
public static ClojurePattern compile(String regex){ | |
return new ClojurePattern(regex,0); |
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
(def & comp) | |
(def p partial) | |
(defn- sym->key [x] (keyword (str x))) | |
(defn- sym-rep [x s-map] | |
(let [k (sym->key x)] | |
(if (contains? s-map k) | |
(s-map k) | |
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
(ns crr.launch-once | |
(:require | |
[clojure.contrib [duck-streams :as duck]]) | |
(:use | |
lib.sfd.swing.messages | |
lib.sfd.thread-utils | |
)) | |
;(def my-agent (agent 0)) |
OlderNewer