annotate 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
rev   line source
rlm@0 1 (ns coderloop.top-five2
rlm@0 2 (:refer-clojure :only [])
rlm@0 3 (:require rlm.ns-rlm rlm.light-base))
rlm@0 4 (rlm.ns-rlm/ns-clone rlm.light-base)
rlm@0 5
rlm@0 6 (use 'coderloop.parallel-io)
rlm@0 7
rlm@0 8 (def a (file-str "/home/r/coderloop-test/topfive-a.in"))
rlm@0 9 (def b (file-str "/home/r/coderloop-test/topfive-b.in"))
rlm@0 10 (def c (file-str "/home/r/coderloop-test/topfive-c.in"))
rlm@0 11 (def d (file-str "/home/r/coderloop-test/topfive-d.in"))
rlm@0 12 (def e (file-str "/home/r/coderloop-test/topfive-e.in"))
rlm@0 13 (def f (file-str "/home/r/coderloop-test/topfive-f.in"))
rlm@0 14
rlm@0 15 (set! *warn-on-reflection* true)
rlm@0 16
rlm@0 17 (defn #^"[Ljava.lang.String;" dumbest-split*
rlm@0 18 [#^String s c #^"[Ljava.lang.String;" tokens]
rlm@0 19 (let [len (dec (int (alength tokens)))]
rlm@0 20 (loop [start (int 0)
rlm@0 21 i (int 0)]
rlm@0 22 (let [idx (int (.indexOf s (int c) (int start)))]
rlm@0 23 (if (or (neg? idx) (>= i len))
rlm@0 24 (do (aset tokens i (.substring s start))
rlm@0 25 tokens)
rlm@0 26 (do (aset tokens i (.substring s start idx))
rlm@0 27 (recur (inc idx) (inc i))))))))
rlm@0 28
rlm@0 29 (defn get-query-1 [s]
rlm@0 30 (nth (re-matches #"^.*, query=(.*)]$" s) 1))
rlm@0 31
rlm@0 32
rlm@0 33 (defn #^java.lang.String get-query-2 [#^java.lang.String s]
rlm@0 34 (.substring s (clojure.core/+ (.lastIndexOf s "query=") 6) (clojure.core/- (.length s) 1)))
rlm@0 35
rlm@0 36 (defn #^java.lang.String get-query-3 [#^java.lang.String s]
rlm@0 37 )