最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

clojure套地图

SEO心得admin37浏览0评论
本文介绍了clojure套地图 - 基本过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Clojure初学者在这里..

Clojure beginner here..

如果我有一组地图,例如

If I have a set of maps, such as

(def kids #{{:name "Noah" :age 5} {:name "George":age 3} {:name "Reagan" :age 1.5}})

我知道我可以得到这样的名字

I know I can get names like this

(map :name kids)

如何选择特定地图?例如我想回到地图,其中name =Reagan。

1) How do I select a specific map? For example I want to get back the map where name="Reagan".

{:name "Reagan" :age 1.5}

可以使用过滤器吗?

2)如何返回age = 3的名称?

2) How about returning the name where age = 3?

推荐答案

p>是的,您可以使用过滤器:

Yes, you can do it with filter:

(filter #(= (:name %) "Reagan") kids) (filter #(= (:age %) 3) kids)
发布评论

评论列表(0)

  1. 暂无评论