作为一个 Wolfram 程序员

如何写出好的代码
核心思想在于:大多数情况下,Mathematica 程序运行缓慢是因为许多 Mathematica 函数过于通用。这种通用性是一大优势,因为它使语言能够支持更好、更强大的抽象,但在程序的许多地方,不加注意地使用这种通用性可能会造成巨大的杀伤。
本笔记本已发布到 Wolfram Cloud。
前言

第 0 章:一点小技巧

第 1 章:底层

第 2 章:模式

第 3 章:循环

第 4 章:数值

第 5 章:变量

后记

参考资料: Wolfram 系统的内部 - Wolfram 语言与系统参考资料中心​ Jon McLoone - 10 Tips for Writing Fast Mathematica Code - Wolfram blog​ 为什么在 Mathematica 中使用循环是低效的? - 知乎​ Why should I avoid the For loop in Mathematica? - Mathematica StackExchange​ Performance tuning in Mathematica? - Mathematica StackExchange​ "performance-tuning" tag summary - Mathematica StackExchange​ What are the most common pitfalls awaiting new users? - Mathematica StackExchage​ What is a Mathematica packed array? - Mathematica StackExchage​ What is the distinction between DownValues, UpValues, SubValues, and OwnValues? - Mathematica StackExchange
本笔记本所有计算的运行环境为:Wolfram 14.3 桌面版 版本号:14.3.0.0 平台:Microsoft Windows (64-bit)设备信息: CPU:12th Gen Intel(R) Core(TM) i7-12700KF RAM:32GB系统信息: 版本:Windows 10 专业版 版本:22H2 OS内部版本:19045.6466​