(-> person :employer :address :city) would be my pick

Vincent

On Jan 28, 4:02 pm, Mark Volkmann <r.mark.volkm...@gmail.com> wrote:
> I have a map that describes a person.
> It has a key that describes their address.
> It also has a key for their employer.
> The employer has its own address.
>
> (def person {
>   :name "Mark Volkmann"
>   :address {
>     :street "644 Glen Summit"
>     :city "St. Charles"
>     :state "Missouri"
>     :zip 63304}
>   :employer {
>     :name "Object Computing, Inc."
>     :address {
>       :street "12140 Woodcrest Executive Drive, Suite 250"
>       :city "Creve Coeur"
>       :state "Missouri"
>       :zip 63141}}})
>
> Is this the best way to retrieve the employer city?
> (reduce get person [:employer :address :city])
>
> Is this the best way to get a new map where the city is changed?
> (update-in person [:employer :address :city] (fn [old & args] "Clayton"))
> I can't get this to work with #("Clayton") in place of the anonymous
> function above.
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to