在Clojure中处理两个序列的值对 [英] Processing pairs of values from two sequences in Clojure
本文介绍了在Clojure中处理两个序列的值对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图进入Clojure社区。我一直在使用Python工作,我广泛使用的功能之一是zip()方法,用于迭代的值对。
解决方案
另一种方法是简单地使用map和一些函数按顺序收集其参数,如下所示:
user => (map vector'(1 2 3)abc)
pre>
([1 \a] [2 \b] [3 \c])
I'm trying to get into the Clojure community. I've been working a lot with Python, and one of the features I make extensive use of is the zip() method, for iterating over pairs of values. Is there a (clever and short) way of achieving the same in Clojure?
解决方案Another way is to simply use map together with some function that collects its arguments in a sequence, like this:
user=> (map vector '(1 2 3) "abc") ([1 \a] [2 \b] [3 \c])
这篇关于在Clojure中处理两个序列的值对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文