Last active
May 24, 2016 23:45
-
-
Save piotr-yuxuan/684a045f08644fdcfeea4cdccca786a2 to your computer and use it in GitHub Desktop.
read effective structure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def firsts | |
'((rand-nth [:a :b :c]) | |
(rand-nth ["TW" "DE" "UK" "FR" "US" "JP"]) | |
(rand-nth [:bob :alice :charles :georges :matz :is :nice]))) | |
(def key-length 2) | |
(def sample-depth 300) | |
(def sample | |
(->> (repeat (+ key-length 2) '(rand-int 10)) | |
(concat firsts) | |
(repeat sample-depth) | |
(map (partial map eval)))) | |
(def structure | |
"If we have to ingest a real database (sorted) output, it's faster | |
to be stateful with threshold effect." | |
(group-by (partial take key-length) sample)) | |
(defn get-tuples | |
[[& args]] | |
(assert (= key-length (count args)) | |
"Key isn't well-sized") | |
(get structure args)) | |
(def easy-test-key | |
(ffirst structure)) | |
(println "Let's test with this easy key:") | |
(pprint easy-test-key) | |
(let [result (get-tuples easy-test-key)] | |
(pprint result) | |
result) | |
;; Well, strongly reminds me | |
;; https://github.com/piotr-yuxuan/autocompletion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment