To nreverse when consing a list or by pointer manipulation, to avoid it; that is the question

R. Waters
{"title":"To nreverse when consing a list or by pointer manipulation, to avoid it; that is the question","authors":"R. Waters","doi":"10.1145/181889.181892","DOIUrl":null,"url":null,"abstract":"A situation that arises all the time in Lisp is the need to create a list of elements where the order of the elements in the list is the same as the order that they are created in time---i.e., the first element computed is the first element in the list, the second element computed is the second element in the list, etc. There are two basic ways of doing this: the nreverse approach and the rplacd approach. In the nreverse approach, you push the elements onto the list as they are computed and then use nreverse to put the list into the correct order after all of the elements have been computed. In the rplacd approach, you maintain a pointer to the end of the list and use rplacd to put each element directly into its proper place in the list.","PeriodicalId":262740,"journal":{"name":"ACM SIGPLAN Lisp Pointers","volume":"46 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"1993-10-01","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"ACM SIGPLAN Lisp Pointers","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/181889.181892","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0

Abstract

A situation that arises all the time in Lisp is the need to create a list of elements where the order of the elements in the list is the same as the order that they are created in time---i.e., the first element computed is the first element in the list, the second element computed is the second element in the list, etc. There are two basic ways of doing this: the nreverse approach and the rplacd approach. In the nreverse approach, you push the elements onto the list as they are computed and then use nreverse to put the list into the correct order after all of the elements have been computed. In the rplacd approach, you maintain a pointer to the end of the list and use rplacd to put each element directly into its proper place in the list.
在考虑列表或通过指针操作时进行反向操作,以避免它;这就是问题所在
在Lisp中经常出现的一种情况是,需要创建一个元素列表,其中元素的顺序与它们在时间中创建的顺序相同。,计算的第一个元素是列表中的第一个元素,计算的第二个元素是列表中的第二个元素,以此类推。有两种基本方法:反向方法和替换方法。在nreverse方法中,在计算元素时将元素推入列表,然后在计算完所有元素后使用nreverse将列表按正确顺序排列。在rplacd方法中,维护一个指向列表末尾的指针,并使用rplacd将每个元素直接放到列表中的适当位置。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术官方微信