Skip to content

Instantly share code, notes, and snippets.

@rlm
rlm / multimethod_recursion.clj
Created December 19, 2010 18:31
an example of recursion with re-dispatch on multimethods
(defmulti redis class)
(defmethod redis java.lang.Integer [x] x)
(defmethod redis java.lang.Double [x]
(let [res (if (< (- x (int (floor x))) 0.01)
(int x)
(/ x 2))]
(println x)
(fn [] ((get-method redis ((.dispatchFn redis) res)) res))
@rlm
rlm / rlm_commands.clj
Created December 19, 2010 18:23
automatic reloading of namespaces
(ns rlm.rlm-commands
(:require [clojure.contrib [duck-streams :as ds]])
(:use [clojure.contrib java-utils]))
(defmacro undef
"removes symbol from the current namespace"
[symbol]
`(ns-unmap *ns* (quote ~symbol)))
(defmacro ns-nuke
@rlm
rlm / gist:746185
Created December 18, 2010 05:19
curry.clj
(ns sunil.curry)
(defn partial+
"Takes a function f and fewer than the normal arguments to f, and
returns a fn that takes a variable number of additional args. When
called, the returned function calls f with args + additional args.
differs from the core version in that it works on just one argument."
{:added "1.0"}
([f] f)
([f arg1]
(ns rlm.shell-write
(:refer-clojure :exclude [spit] )
(:use [clojure.contrib duck-streams command-line str-utils shell-out repl-utils])
(:import (java.io File BufferedReader ByteArrayOutputStream InputStreamReader))
(:import (org.apache.commons.exec PumpStreamHandler DefaultExecutor ExecuteWatchdog CommandLine)))
(defn sw
"same as sh but uses apache-commons to actually execute the process,
and prints output as soon as the subprocess returns output. Prints all
(ns
mobius.utils.function-utils
"Collection of Operators on Pure Functions"
{:author "Robert McIntyre"}
(:use [clojure.contrib.profile]))
(defn mix
" Takes any number of mathematically equal functions with possibly different run-time properties and
returns a function that runs each in a separate thread, returns the result from the first thread
;; Various Operators on Pure Functions
;;
;; Open source Liscence and all that
(ns
"Collection of Operators on Pure Functions"
{:author "Robert McIntyre"}
mobius.utils.function-utils
(:use [clojure.contrib.profile]))