有没有更好的方法来浏览clojure中的嵌套地图.例如,对于以下地图:
{
  :one{
    :two {
      :three value
     }
   }
}
为了获得:three我所做的价值,(:three (:two (:one mymap)))但是如果有我可以做的线程之类的话会更好(-> mymap :one :two :three)
核心功能get-in完全符合您的要求
Returns the value in a nested associative structure,
where ks is a sequence of ke(ys. Returns nil if the key is not present,
or the not-found value if supplied.
(get-in your-nested-data [:one :two :three])
http://clojuredocs.org/clojure_core/clojure.core/get-in
"如果有我可以做的线程,会更好(-> mymap :one :two :three)"
谁说你做不到?你的确切语法有效!
so.core=> (def mymap { :one, { :two, { :three :value } } })
#'so.core/mymap
so.core=> (-> mymap :one :two :three)
:value
| 归档时间: | 
 | 
| 查看次数: | 204 次 | 
| 最近记录: |