Mathematica: Unevaluated vs Defer vs Hold vs HoldForm vs HoldAllComplete vs etc等

编程入门 行业动态 更新时间:2024-10-27 08:25:45
本文介绍了Mathematica: Unevaluated vs Defer vs Hold vs HoldForm vs HoldAllComplete vs etc等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我对所有声称以某种方式阻止评估的内置 Mathematica 函数感到困惑:Unevaluated、Defer、Hold,以及超过六种 Hold* 形式.Mathematica 文档只是单独解释了每个函数,而没有解释为什么要选择其中一个.任何人都可以对所有这些功能提供一个连贯的解释吗?整件事对我来说似乎是一团糟.将这一切与 Lisp 宏联系起来可能是一个不错的起点.

I'm bewildered by all the built-in Mathematica functions that purport to prevent evaluation in some way: Unevaluated, Defer, Hold, and over half a dozen of the form Hold*. The Mathematica documentation just explains each function in isolation without explaining why you would choose one or the other. Can anyone offer a coherent explanation of all these functions? The whole thing seems like a convoluted mess to me. Relating it all to Lisp macros might be a good place to start.

Mathematica 语言的大部分设计都非常出色,但 Wolfram 似乎真的在这方面把自己画到了一个角落.或者我可能会遗漏一些东西.

Most of the Mathematica language is amazingly well-designed but it seems like Wolfram really painted himself into a corner on this aspect. Or I could be missing something.

推荐答案

这些都是相当棘手的结构,很难给出清晰的解释;它们不像 Lisp 宏那样简单(或者,就此而言,Lisp 的 QUOTE 和 EVAL 之间的关系).然而,在 罗比·维勒加斯 1999 年演讲未评估的表达式"中的笔记中,有一个很好的、冗长的讨论" 在 Wolfram 的网站上.

These are pretty tricky constructs, and it's tough to give clear explanations; they aren't as straightforward as Lisp macros (or, for that matter, the relationship between Lisp's QUOTE and EVAL). However, there's a good, lengthy discussion available in the form of notes from Robby Villegas's 1999 talk "Unevaluated Expressions" on Wolfram's website.

Defer 从那次谈话中省略了,因为它是 Mathematica 6.0 的新内容.它很像 HoldForm,除了当它在前端(但不是裸内核)中输出时,它会被剥离,留下一个可以用作输入的表达式.如果您想以编程方式构建用户可以编辑和评估的表达式,例如在调色板中,这将非常有用.

Defer is omitted from that talk, because it's new as of Mathematica 6.0. It's a lot like HoldForm, except that when it's output in a front-end (but not a bare kernel) it's stripped away, leaving an expression that can be used as input. This is very useful if you want to programmatically construct expressions that a user can edit and evaluate, say in a palette.

更多推荐

Mathematica: Unevaluated vs Defer vs Hold vs HoldForm vs HoldAllComplete vs etc等

本文发布于:2023-11-07 06:54:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565819.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Defer   Unevaluated   Mathematica   HoldAllComplete   HoldForm

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!