从clojure中查找多个集合的列表 [英] Find lists from multiple collections in clojure
本文介绍了从clojure中查找多个集合的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是clojure的新手。我面临的一个问题是从多个集合中找到特殊的列表。
- 列出一个:(1 2 3 4 5)
- 列出两个:(abcdef)
源列表:(1 c 2 b 4 eaf)
列出要在源列表中找到: 1),(1a),(4c),(f 2)
如何解决?
谢谢
解决方案
查看 https://github.com/clojure/math.combinatorics
=> (combo / cartesian-product [1 2] [3 4])
pre>
(1 3)(1 4)(2 3)(2 4))
I am a newbie to clojure. One question I am facing is to find special lists from multiple collections.
- list one: (1 2 3 4 5)
- list two: (a b c d e f)
Source list: (1 c 2 b 4 e a f)
Lists to find in the source list: (a 1), (1 a), (4 c), (f 2)How to resolve it?
Thanks解决方案Have a look at https://github.com/clojure/math.combinatorics
=> (combo/cartesian-product [1 2] [3 4]) ((1 3) (1 4) (2 3) (2 4))
这篇关于从clojure中查找多个集合的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文