Last active
September 6, 2019 06:10
-
-
Save verma/96ca5070d8556ccb5fe2 to your computer and use it in GitHub Desktop.
pre-walk vs. post-walk
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
:profile_data | |
:ber | |
:value | |
11 | |
[:value 11] | |
{:value 11} | |
[:ber 11] | |
:event_type | |
:value | |
foo | |
[:value foo] | |
{:value foo} | |
[:event_type foo] | |
{:ber 11, :event_type foo} | |
[:profile_data {:ber 11, :event_type foo}] | |
:conservatories | |
:area | |
:value | |
10 | |
[:value 10] | |
{:value 10} | |
[:area 10] | |
:height | |
:value | |
11 | |
[:value 11] | |
{:value 11} | |
[:height 11] | |
{:area 10, :height 11} | |
:area | |
:value | |
2 | |
[:value 2] | |
{:value 2} | |
[:area 2] | |
:height | |
:value | |
1 | |
[:value 1] | |
{:value 1} | |
[:height 1] | |
{:area 2, :height 1} | |
[{:area 10, :height 11} {:area 2, :height 1}] | |
[:conservatories [{:area 10, :height 11} {:area 2, :height 1}]] | |
:timestamp | |
:value | |
1 | |
[:value 1] | |
{:value 1} | |
[:timestamp 1] | |
{:profile_data {:ber 11, :event_type foo}, :conservatories [{:area 10, :height 11} {:area 2, :height 1}], :timestamp 1} | |
{:profile_data {:ber 11, :event_type "foo"}, :conservatories [{:area 10, :height 11} {:area 2, :height 1}], :timestamp 1} |
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 input {:profile_data {:ber {:value 11}, :event_type {:value "foo"}}, :conservatories [{:area {:value 10}, :height {:value 11}} {:area {:value 2}, :height {:value 1}}], :timestamp {:value 1}}) | |
(def input {:profile_data {:ber {:value 11}, :event_type {:value "foo"}}, :conservatories [{:area {:value 10}, :height {:value 11}} {:area {:value 2}, :height {:value 1}}], :timestamp {:value 1} :other-stuff {:value nil}}) | |
(clojure.walk/prewalk #(do | |
(println %) | |
(if (and (map? %) | |
(contains? % :value)) | |
(:value %) %)) input) | |
(clojure.walk/postwalk #(do | |
(println %) | |
(if (and (map? %) | |
(contains? % :value)) | |
(:value %) %)) input) | |
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
{:profile_data {:ber {:value 11}, :event_type {:value foo}}, :conservatories [{:area {:value 10}, :height {:value 11}} {:area | |
{:value 2}, :height {:value 1}}], :timestamp {:value 1}} | |
[:profile_data {:ber {:value 11}, :event_type {:value foo}}] | |
:profile_data | |
{:ber {:value 11}, :event_type {:value foo}} | |
[:ber {:value 11}] | |
:ber | |
{:value 11} | |
[:event_type {:value foo}] | |
:event_type | |
{:value foo} | |
[:conservatories [{:area {:value 10}, :height {:value 11}} {:area {:value 2}, :height {:value 1}}]] | |
:conservatories | |
[{:area {:value 10}, :height {:value 11}} {:area {:value 2}, :height {:value 1}}] | |
{:area {:value 10}, :height {:value 11}} | |
[:area {:value 10}] | |
:area | |
{:value 10} | |
[:height {:value 11}] | |
:height | |
{:value 11} | |
{:area {:value 2}, :height {:value 1}} | |
[:area {:value 2}] | |
:area | |
{:value 2} | |
[:height {:value 1}] | |
:height | |
{:value 1} | |
[:timestamp {:value 1}] | |
:timestamp | |
{:value 1} | |
{:profile_data {:ber 11, :event_type "foo"}, :conservatories [{:area 10, :height 11} {:area 2, :height 1}], :timestamp 1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment