Skip to content

Instantly share code, notes, and snippets.

View xumingming's full-sized avatar

James Xu xumingming

  • -
  • -
View GitHub Profile
package com.alibaba.dubbo.demo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.dubbo.common.utils.Assert;
import com.alibaba.dubbo.config.ApplicationConfig;
@xumingming
xumingming / joy-of-clojure-lazy-qsort.clj
Created September 29, 2012 14:16 — forked from killme2008/joy-of-clojure-lazy-qsort.clj
Lazy QuickSort implementation in Clojure, from Joy of Clojure chapter 6.
(ns joy.q)
;; nil
(defn nom [n] (take n (repeatedly #(rand-int n))))
;; #'joy.q/nom
(defn sort-parts [work]
(lazy-seq
(loop [[part & parts] work] ;; Pull apart work - note: work will be a list of lists.
(if-let [[pivot & xs] (seq part)] ;; This blows up unless work was a list of lists.
;;; See the inspirational SO question: http://stackoverflow.com/questions/3346382
(require 'clojure.contrib.trace)
(defn trace-ns
"Replaces each function from the given namespace with a version wrapped
in a tracing call. Can be undone with untrace-ns. ns should be a namespace
object or a symbol."
[ns]
(doseq [s (keys (ns-interns ns))