通过不使用评估菜单的命令退出mathematica中的内核
我希望当我评估笔记本时,它首先退出最后一个本地内核,然后再次启动本地内核。是否有任何命令可以在不使用 Mathematica 中的评估菜单的情况下执行此操作?
I would like that when I evaluate a notebook it first quits the last local kernel and then starts local kernel again. Is there any command to do this without using the Evaluation menu in Mathematica?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Quit[]
可用于终止内核,然后笔记本中评估的任何其他内容都将再次启动它。如果您想要这样做的原因是为了确保笔记本中运行的内容不会与任何先前定义的符号冲突,那么您可以设置菜单:
如果您希望
Quit[]
经常使用内核,那么你不妨设置一个键盘快捷键。为此,请参阅此答案:自定义 Mathematica 快捷方式
如果您发现 Mathematica 在以下情况下速度变慢处理一个长笔记本的中间部分,并且该笔记本的后面部分不依赖于前面的部分,您可能希望将其插入到笔记本的开头:
和然后插入:
您想要
Quit[]
效果的位置Quit[]
can be used to terminate the kernel, and then anything else evaluated in the notebook will start it again.If the reason you want to do this is to make sure that what is run in the notebook does not conflict with any previously defined symbols, then you may instead set menu:
If you are wishing to
Quit[]
the kernel frequently, then you may wish to set up a keyboard shortcut. For that, see this answer:Customizing Mathematica shortcuts
If you find that Mathematica slows down in the middle of processing a long notebook, and the latter parts of that notebook do not depend on the earlier parts, you may wish insert this at the beginning of your notebook:
and then insert:
where you want the effect of
Quit[]
我可以建议的唯一解决方案是通过 MathLink 使用从属内核。它允许您随时重新启动从属内核,并在自动重新启动时做出额外的规则。当然,主内核不会重启,只是作为从内核的接口。您可以在 此线程。
The only solution I can suggest is to use slave kernel through
MathLink
. It allows you to restart the slave kernel whenever you wish and make additional ruled when it will be restarted automatically. Of course, the master kernel will not be restarted and will be used just as an interface for the slave kernel. The general ideas for this you can find in this thread.