diff src/top_five2.clj @ 0:307a81e46071 tip

initial committ
author Robert McIntyre <rlm@mit.edu>
date Tue, 18 Oct 2011 01:17:49 -0700
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/top_five2.clj	Tue Oct 18 01:17:49 2011 -0700
     1.3 @@ -0,0 +1,37 @@
     1.4 +(ns coderloop.top-five2
     1.5 +  (:refer-clojure :only [])
     1.6 +  (:require rlm.ns-rlm rlm.light-base))
     1.7 +(rlm.ns-rlm/ns-clone rlm.light-base)
     1.8 +
     1.9 +(use 'coderloop.parallel-io)
    1.10 +
    1.11 +(def a (file-str "/home/r/coderloop-test/topfive-a.in"))
    1.12 +(def b (file-str "/home/r/coderloop-test/topfive-b.in"))
    1.13 +(def c (file-str "/home/r/coderloop-test/topfive-c.in"))
    1.14 +(def d (file-str "/home/r/coderloop-test/topfive-d.in"))
    1.15 +(def e (file-str "/home/r/coderloop-test/topfive-e.in"))
    1.16 +(def f (file-str "/home/r/coderloop-test/topfive-f.in"))
    1.17 +
    1.18 +(set! *warn-on-reflection* true)
    1.19 +
    1.20 +(defn #^"[Ljava.lang.String;" dumbest-split*
    1.21 +  [#^String s c #^"[Ljava.lang.String;" tokens]
    1.22 +  (let [len (dec (int (alength tokens)))]
    1.23 +    (loop [start (int 0)
    1.24 +	   i (int 0)]
    1.25 +      (let [idx (int (.indexOf s (int c) (int start)))]
    1.26 +	(if (or (neg? idx) (>= i len))
    1.27 +	  (do (aset tokens i (.substring s start))
    1.28 +	      tokens)
    1.29 +	  (do (aset tokens i (.substring s start idx))
    1.30 +	      (recur (inc idx) (inc i))))))))
    1.31 +
    1.32 +(defn get-query-1 [s]
    1.33 +     (nth (re-matches #"^.*, query=(.*)]$" s) 1))
    1.34 +
    1.35 +
    1.36 +(defn #^java.lang.String get-query-2 [#^java.lang.String s]
    1.37 +   (.substring s (clojure.core/+ (.lastIndexOf s "query=") 6) (clojure.core/- (.length s) 1)))
    1.38 +
    1.39 +(defn #^java.lang.String get-query-3 [#^java.lang.String s]
    1.40 +  )