在Clojure中,我应该何时在列表上使用向量,反之亦然? [英] In Clojure, when should I use a vector over a list, and the other way around?

查看:218
本文介绍了在Clojure中,我应该何时在列表上使用向量,反之亦然?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到矢量不是seqs,但列表是。我不知道使用一个的理由是什么。看起来矢量是最多使用的,但有什么原因吗?任何答案都感谢,谢谢!

I read that Vectors are not seqs, but Lists are. I'm not sure what the rationale is for using one over the other. It seems that vectors are used the most, but is there a reason for that? Any answers are appreciated, thanks!

推荐答案

再次,似乎我已经回答了我自己的问题,在#clojure在Freenode。在Stackoverflow.com上鼓励回答您自己的问题:D

Once again, it seems I've answered my own question by getting impatient and asking it in #clojure on Freenode. Good thing answering your own questions is encouraged on Stackoverflow.com :D

我与Rich Hickey进行了一次快速讨论,这里是它的要点。

I had a quick discussion with Rich Hickey, and here is the gist of it.

[12:21] <Raynes>    Vectors aren't seqs, right?
[12:21] <rhickey>   Raynes: no, but they are sequential
[12:21] <rhickey>   ,(sequential? [1 2 3])
[12:21] <clojurebot>    true
[12:22] <Raynes>    When would you want to use a list over a vector?
[12:22] <rhickey>   when generating code, when generating back-to-front
[12:23] <rhickey>   not too often in Clojure

这篇关于在Clojure中,我应该何时在列表上使用向量,反之亦然?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆