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 merge-sorted [comparator & xss] | |
(let [xss (into-array Object (remove empty? xss)) | |
pq (java.util.PriorityQueue. | |
(count xss) #(comparator (val %1) (val %2)))] | |
(dotimes [i (count xss)] | |
(let [xs (aget xss i)] | |
(.add pq (pair i (first xs))) | |
(aset xss i (next xs)))) | |
((fn go [] | |
(lazy-seq |
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
function c(a){throw a;}var g=!0,k=null,l=!1;function aa(){return function(a){return a}}function m(a){return function(){return this[a]}}function n(a){return function(){return a}}var o,ba=this; | |
function q(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var d=Object.prototype.toString.call(a);if("[object Window]"==d)return"object";if("[object Array]"==d||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==d||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null"; | |
else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function r(a){return void 0!==a}function ca(a){return"string"==typeof a}function da(a){return a[ea]||(a[ea]=++fa)}var ea="closure_uid_"+Math.floor(2147483648*Math.random()).toString(36),fa=0;function s(a,b){var d=a.split( |
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
function c(a){throw a;}var g=!0,k=null,l=!1;function aa(){return function(a){return a}}function m(a){return function(){return this[a]}}function n(a){return function(){return a}}var o,ba=this; | |
function q(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var d=Object.prototype.toString.call(a);if("[object Window]"==d)return"object";if("[object Array]"==d||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==d||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null"; | |
else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function s(a){return void 0!==a}function ca(a){return"string"==typeof a}function da(a){return a[ea]||(a[ea]=++fa)}var ea="closure_uid_"+Math.floor(2147483648*Math.random()).toString(36),fa=0;function t(a,b){var d=a.split( |
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
;;; See the inspirational SO question: http://stackoverflow.com/questions/3346382 | |
;;; My old Gist with my first take on this: https://gist.github.com/492764 | |
;;; Don Jackson's Gist based on the above: https://gist.github.com/1846993 | |
;;; Licence: EPLv1, the same as Clojure | |
(in-ns 'clojure.tools.trace) | |
(defn trace-var | |
"If the specified Var holds an IFn and is not marked as a macro, its |
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
;;; See | |
;;; http://stackoverflow.com/questions/7240947/is-a-transparent-macrolet-possible | |
;;; for a discussion. | |
;;; Also see | |
;;; https://gist.github.com/1185513 | |
;;; for an earlier approach. | |
;;; src/deftest-magic/core.clj |
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
;;; See | |
;;; http://stackoverflow.com/questions/7240947/is-a-transparent-macrolet-possible | |
;;; for a discussion. | |
;;; src/deftest_magic/core.clj | |
(ns deftest-magic.core | |
(:use [clojure.tools.macro :only [macrolet]])) | |
(comment |
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 letrec [bindings & body] | |
(let [bcnt (quot (count bindings) 2) | |
arrs (gensym "bindings_array") | |
arrv `(make-array Object ~bcnt) | |
bprs (partition 2 bindings) | |
bssl (map first bprs) | |
bsss (set bssl) | |
bexs (map second bprs) | |
arrm (zipmap bssl (range bcnt)) | |
btes (map #(walk/prewalk (fn [f] |
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 unuse [ns] | |
(doseq [[n v] (ns-refers *ns*)] | |
(if (= (.. v ns name) ns) | |
(ns-unmap *ns* n)))) | |
(defn reuse [ns] | |
(unuse ns) | |
(remove-ns ns) | |
(use :reload-all ns)) |
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 intern-alias | |
"Interns a Var called alias-sym in the namespace given by ns-or-sym | |
(which may be a symbol or an actual namespace object; defaults to | |
the current namespace). The binding of the new Var will be that of | |
the Var specified as var-or-sym; also, all metadata is copied from | |
the original to the alias. The original may be specified as either | |
a Var or a symbol." | |
([alias-sym var-or-sym] | |
(intern-alias *ns* alias-sym var-or-sym)) | |
([ns-or-sym alias-sym var-or-sym] |