Use this version of SLIME:
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 c-rand-int | |
"Returns a random int >= lower and <= upper, that doesn't equal forbid" | |
[lower upper forbid] | |
(let [rval (+ (rand-int (+ upper 1)) lower)] | |
(if (= forbid rval) | |
(recur lower upper forbid) | |
rval))) |
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
(defun cljr-swank () | |
(interactive) | |
(let ((proc (start-process-shell-command | |
"cljr-swank" "*cljr-swank*" | |
"cljr") "swank" | |
(number-to-string slime-port)))) | |
(when proc | |
(process-put proc :output nil) | |
(set-process-sentinel | |
proc (lambda (proc event) |
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 mergesortv [coll] | |
(if (<= (count coll) 1) | |
coll | |
(let [middle (quot (count coll) 2) | |
left (mergesortv (subvec coll 0 middle)) | |
right (mergesortv (subvec coll middle))] | |
(loop [left left right right l []] | |
(cond (empty? left) (into l right) | |
(empty? right) (into l left) | |
(< (first left) (first right)) |
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 longest-equal-subseq-for | |
"Returns the longest subsequence of indices for which the following | |
statement is true: | |
for all i, j in subsequence: (f i) = (f j) != nil | |
If there are subsequences of equal size, the last one is returned." | |
[f indices] | |
(let [subseqs (remove (comp nil? first) (partition-by f indices))] | |
(if (seq subseqs) | |
(apply (partial max-key count) subseqs) | |
subseqs))) |
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 replace-symbols | |
"Given a map of replacement pairs and a form, returns a (nested) | |
form with any symbol = a key in smap replaced with the corresponding | |
val in smap." | |
[smap form] | |
(if (sequential? form) | |
(map (partial replace-symbols smap) form) | |
(get smap form form))) | |
(defmacro lazy-let |
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
(defmacro create | |
"Dynamic factory for defrecords." | |
([name] `(create ~name {}) ) | |
([name vals-map] | |
`(let [con# (first (.getDeclaredConstructors ~name)) | |
num# (alength (.getParameterTypes | |
^java.lang.reflect.Constructor con#))] | |
(merge (.newInstance ^java.lang.reflect.Constructor | |
con# (make-array Object num#)) ~vals-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 wow | |
(:use ring.adapter.jetty | |
[ring.middleware params file-info reload file stacktrace)]) |
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
(defun sum-column () | |
"Sums a column of numbers starting at point" | |
(interactive) | |
(save-excursion | |
(if (and (not (= (current-column) 0)) | |
(re-search-backward "[ \t]" 0 t )) | |
(forward-char)) | |
(let ((retn 0) | |
(old-column (current-column)) | |
(old-next-line-add-newlines)) |
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
;; Show the number of members in a channel in the mode line | |
(define-minor-mode erc-members-mode "" nil | |
(:eval (format " %S users" (hash-table-count erc-channel-users)))) | |
(add-hook 'erc-mode-hook 'erc-members-mode) |
OlderNewer