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

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

问题描述

我读到向量不是序列,但列表是.我不确定使用一个而不是另一个的理由是什么.似乎向量使用得最多,但这有什么原因吗?

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?

推荐答案

似乎我已经不耐烦地回答了我自己的问题,并在 Freenode 上的 #clojure 中提问.鼓励在 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天全站免登陆