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