Lazy evaluation is a powerful technique that can optimize code execution by deferring evaluations until their results are required, thus enhancing efficiency. In most modern programming languages, like R, lazy evaluation is commonly applied to function arguments. However, the application of lazy evaluation in SAS has not been extensively explored. This paper focuses on the mechanisms of lazy evaluation in SAS MACROs and R functions, offering a comparative analysis of the underlying principles that drive these processes. R's lazy evaluation is driven by a data structure called Promise, which postpones evaluation and does not occupy memory until the value is needed, utilizing a call-by-need strategy. SAS, on the other hand, achieves lazy evaluation through its symbol tables, employing memory to store parameters, and operates on a call-by-name basis. These discrepancies in lazy evaluation strategies can notably impact the results of R functions and SAS MACROs. By examining these distinct approaches, the paper illuminates the impact of lazy evaluation on programming efficiency, supported by illustrative examples. As the shift from SAS to R becomes increasingly prevalent in the pharmaceutical industry, understanding these techniques enables programmers to optimize their code for greater efficacy. This exploration serves as a guide to enhance programming capabilities and performance in both languages.


翻译:惰性求值是一种通过推迟计算至需要结果时才执行来优化代码运行的技术,从而提升效率。在大多数现代编程语言(如R)中,惰性求值通常应用于函数参数。然而,SAS中惰性求值的应用尚未得到广泛探索。本文聚焦于SAS MACROs与R函数中惰性求值的实现机制,对驱动这些过程的底层原理进行了比较分析。R的惰性求值由称为Promise的数据结构驱动,该结构推迟求值且不占用内存直至需要该值,采用按需调用策略。而SAS则通过其符号表实现惰性求值,利用内存存储参数,并基于按名调用方式运行。这些惰性求值策略的差异会显著影响R函数与SAS MACROs的运行结果。通过检视这些不同的方法,本文以示例说明惰性求值对编程效率的影响。随着制药行业从SAS转向R的趋势日益普遍,理解这些技术有助于程序员优化代码以提升效能。本探索可作为增强两种语言编程能力与性能的指南。

0
下载
关闭预览

相关内容

【2022新书】机器学习中的概率数值计算,412页pdf
专知会员服务
93+阅读 · 2022年7月7日
【干货书】R语言探索性数据分析,218页pdf
专知会员服务
63+阅读 · 2021年9月14日
数据科学导论,722页pdf,讲述带R的数据分析与预测算法
专知会员服务
59+阅读 · 2021年9月11日
【斯坦福经典书】统计学稀疏性:Lasso与泛化性,362页pdf
专知会员服务
37+阅读 · 2020年11月15日
【2022新书】Python数学逻辑,285页pdf
专知
13+阅读 · 2022年11月24日
数据分析师应该知道的16种回归技术:Lasso回归
数萃大数据
16+阅读 · 2018年8月13日
各种相似性度量及Python实现
机器学习算法与Python学习
11+阅读 · 2017年7月6日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Arxiv
0+阅读 · 1月19日
VIP会员
相关VIP内容
【2022新书】机器学习中的概率数值计算,412页pdf
专知会员服务
93+阅读 · 2022年7月7日
【干货书】R语言探索性数据分析,218页pdf
专知会员服务
63+阅读 · 2021年9月14日
数据科学导论,722页pdf,讲述带R的数据分析与预测算法
专知会员服务
59+阅读 · 2021年9月11日
【斯坦福经典书】统计学稀疏性:Lasso与泛化性,362页pdf
专知会员服务
37+阅读 · 2020年11月15日
相关基金
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员