简体   繁体   English

将Java数组转换为Clojure列表或序列?

[英]Convert a Java array into a Clojure list or sequence?

How do I convert a Java array into a Clojure sequence data structure, such as a list, or other sequence? 如何将Java数组转换为Clojure序列数据结构(如列表或其他序列)?

This question shows how to do the inverse; 这个问题说明了如何做逆; The Clojure docs show how to create, mutate, and read arrays; Clojure文档展示了如何创建,变异和读取数组; but is there a built-in way to convert them to lists, or some other Clojure-native sequence? 但有没有内置的方法将它们转换为列表,或其他一些Clojure原生序列?

Yes, there is a way to convert an array to a list! 是的,有一种方法可以将数组转换为列表! The code (seq java-array-here) will convert the array into an ArraySeq , which implements ISeq , and thus can be treated like any other Clojure sequence . 代码(seq java-array-here)将数组转换为ArraySeq ,它实现了ISeq ,因此可以像任何其他Clojure 序列一样对待。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM