一个笔记本中的两个初始化单元分别自动保存在单独的 .m 文件中?
有没有一种方法可以创建笔记本,其中每个初始化Cell
将自动保存在其自己的具有任意名称的.m文件中?
PS 这个问题与 Wolfram Research Inc. 开发的 Mathematica 程序有关。它与数学或数学无关。
Is there a way to create Notebook in which each Initialization Cell
will be auto-saved in its own .m-file with arbitrary name?
P.S. The question is related to the Mathematica program developed by Wolfram Research Inc. It is not about Mathematics or math.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定以下方法是否能让您满意:我曾经想要一种生成紧凑笔记本的方法,其中仅包含我的开发笔记本中找到的初始化单元;以下代码将当前笔记本的初始化单元写入单个新笔记本中,并自动保存 .m 文件作为副作用,但它可以轻松地进行调整,为每个初始化单元生成单独的笔记本和 .m 文件。
这只提取调用函数
extractInitializationCells
的单元下面的初始化单元。我同意之前关于使用自动生成包机制的警告。此外,CurrentValue
并没有无限期地受到向后不兼容的保护,但迄今为止它已经在几个主要的 Mathematica 版本中幸存下来。I'm not sure if the following approach would satisfy you: I once wanted a way of generating compact notebooks containing only the initialisation cells found in my development notebook; the following code writes the initialization cells of the current notebook into a single new notebook and autosaves a .m file as a side-effect but it could easily be adapted to generate a separate notebook and .m file for each initialization cell.
This only extracts the initialisation cells below the cell in which the function
extractInitializationCells
is called. And I'd agree with the previous caveats about using the auto generation package mechanism. Also,CurrentValue
is not protected indefinitely from backwards incompatibility but it has survived several major Mathematica versions so far.