Skip to content

Instantly share code, notes, and snippets.

@jbowles
Created November 23, 2012 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbowles/4136210 to your computer and use it in GitHub Desktop.
Save jbowles/4136210 to your computer and use it in GitHub Desktop.
Horizon TFSG Step, Formula, Hub First Draft
```clojure
;; Clojure Step
(declare step check-valid base-complete check-user)
(defn one-of [coll]
(if (seq coll)
[(rand-nth coll)]))
(defn step[] (concat (check-valid) (base-complete) (check-user)))
(defn check-valid[] (one-of [0 1]))
(defn base-complete[] (one-of ["id" "source_id" "parent_id" "table", "state_type_id"]))
(defn check-user[] (one-of ["product" "web analytics_data" "user_data" "occurrence_type"]))
(take 10 (repeatedly step))
;; Clojure Formula
(declare formula step-one step-two check-valid base-complete check-user)
(defn one-of [coll]
(if (seq coll)
[(rand-nth coll)]))
(defn formula[] (concat (step-one) (step-two)))
(defn step-one[] (concat (check-valid) (base-complete)))
(defn step-two[] (concat (check-user) (check-valid)))
(defn check-valid[] (one-of [0 1]))
(defn base-complete[] (one-of ["id" "source_id" "parent_id" "table", "state_type_id"]))
(defn check-user[] (one-of ["product" "web analytics_data" "user_data" "occurrence_type"]))
(take 10 (repeatedly formula))
;; Clojure Hub
(declare hub node-one node-two formula-one formula-two step-one step-two check-valid base-complete check-user)
(defn one-of [coll]
(if (seq coll)
[(rand-nth coll)]))
(defn hub[] (concat (node-one) (node-two)))
(defn node-one[] (concat (formula-one) (formula-two)))
(defn node-two[] (concat (formula-one) (formula-two)))
(defn formula-one[] (concat (step-one) (step-two)))
(defn formula-two[] (concat (step-one) (step-two)))
(defn step-one[] (concat (check-valid) (base-complete)))
(defn step-two[] (concat (check-user) (check-valid)))
(defn check-valid[] (one-of [0 1]))
(defn base-complete[] (one-of ["id" "source_id" "parent_id" "table", "state_type_id"]))
(defn check-user[] (one-of ["product" "web analytics_data" "user_data" "occurrence_type"]))
(take 10 (repeatedly hub))
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment