方案中的多维向量?
我之前问过一个关于方案中数组的问题(结果它们被称为向量,但在其他方面基本上与您期望的相同)。
有没有一种简单的方法可以在 PLT 方案中处理多维 arrays 向量?出于我的目的,我想要一个名为 make-multid-vector
或其他名称的过程。
顺便说一句,如果这尚不存在,我不需要如何实现它的完整代码示例。如果我必须自己推出这个,我会很感激一些总体方向。我可能会这样做的方法是迭代向量当前最高维度的每个元素以添加另一个维度,但我可以看到使用方案的递归设置有点难看。
另外,这似乎是我应该能够自己找到的东西,所以请知道我确实用谷歌搜索了它,但什么也没有出现。
I earlier asked a question about arrays in scheme (turns out they're called vectors but are basically otherwise the same as you'd expect).
Is there an easy way to do multidimensional arrays vectors in PLT Scheme though? For my purposes I'd like to have a procedure called make-multid-vector
or something.
By the way if this doesn't already exist, I don't need a full code example of how to implement it. If I have to roll this myself I'd appreciate some general direction though. The way I'd probably do it is to just iterate through each element of the currently highest dimension of the vector to add another dimension, but I can see that being a bit ugly using scheme's recursive setup.
Also, this seems like something I should have been able to find myself so please know that I did actually google it and nothing came up.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这两种常见的方法与许多语言中的相同,要么使用向量的向量,要么(更有效地)使用 X*Y 的单个向量并计算每个引用的位置。但是有一个库可以做到这一点 - 在文档中查找
srfi/25
,您可以通过(需要 srfi/25)
获得。The two common approaches are the same as in many languages, either use a vector of vectors, or (more efficiently) use a single vector of X*Y and compute the location of each reference. But there is a library that does that -- look in the docs for
srfi/25
, which you can get with(require srfi/25)
.