Skip to content

Instantly share code, notes, and snippets.

@piotr-yuxuan
Last active May 24, 2016 23:45
Show Gist options
  • Save piotr-yuxuan/684a045f08644fdcfeea4cdccca786a2 to your computer and use it in GitHub Desktop.
Save piotr-yuxuan/684a045f08644fdcfeea4cdccca786a2 to your computer and use it in GitHub Desktop.
read effective structure
(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