Mercurial > coderloop
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:307a81e46071 |
---|---|
1 (ns coderloop.top-five2 | |
2 (:refer-clojure :only []) | |
3 (:require rlm.ns-rlm rlm.light-base)) | |
4 (rlm.ns-rlm/ns-clone rlm.light-base) | |
5 | |
6 (use 'coderloop.parallel-io) | |
7 | |
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")) | |
14 | |
15 (set! *warn-on-reflection* true) | |
16 | |
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)))))))) | |
28 | |
29 (defn get-query-1 [s] | |
30 (nth (re-matches #"^.*, query=(.*)]$" s) 1)) | |
31 | |
32 | |
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))) | |
35 | |
36 (defn #^java.lang.String get-query-3 [#^java.lang.String s] | |
37 ) |