Created
February 11, 2019 16:29
-
-
Save joefromct/0b017d43f381e3f861fc93d08e716213 to your computer and use it in GitHub Desktop.
can i remove the atom?
This file contains 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 airplanes {:planes | |
{:plane | |
[{:make "Cessna", | |
:year "1977", | |
:model {:#text "MoonDart", :at-color "blue"}, | |
:owner ["mitch" "glen" "paulie"], | |
:action | |
[{:#text "sample text - landed the plane and it was windy.", | |
:at-type "landing", | |
:at-weather "windy", | |
:at-whitespace_attribute "whitespace-> "} | |
{:#text "sample\ntext - landed the plane and it was sunny.", | |
(pprint airplanes) | |
:at-type "landing", | |
:at-weather "sunny"}]} | |
{:make "Cessna", | |
:year "1933", | |
:model {:#text "Skyhawk", :at-color "blue"}, | |
:owner "jim", | |
:action {:#text "text!", :at-type "takeoff", :at-weather "windy"}} | |
{:make "whitespace->>", | |
:year "1833", | |
:model {:#text "puppy", :at-color "blue"}, | |
:owner "hal", | |
:action | |
{:#text "more with whitespace->>", | |
:at-type "takeoff", | |
:at-weather "blowy"}}]}}) | |
;; how do i get rid of the atom? do i _have_ to use core.async? I was hoping to somehow use the `acc` as an accumulator. ? | |
(def output (atom [])) | |
(defn recur-test[{:keys [acc val md5-list json-key] | |
:or {acc [] | |
md5-list [] | |
json-key []} | |
:as args}] | |
(if-let [new-md5 (md5 (json/generate-string val))] | |
(cond | |
(map? val) (do | |
(swap! output | |
conj {:md5-list (conj md5-list new-md5) | |
:json-key json-key | |
:val val}) | |
(doseq [[k,v] val] | |
(recur-test (merge args | |
{:md5-list (conj md5-list new-md5) | |
:json-key (conj json-key k) | |
:val v} | |
)))) | |
(vector? val) (do | |
#_(printf "V -> %s\n" val) | |
(doseq [v val] (recur-test (assoc args :val v))) | |
) | |
;; if it's anything eles it should be contained in the maps above? | |
:else () #_(pprint {:json-key json-key | |
:md5-list md5-list' | |
:val val}) | |
))) | |
(recur-test {:val airplanes} ) | |
(clojure.pprint/print-table @output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment