ConfirmBy
ConfirmBy[expr,f]
confirms that f[expr] returns True, otherwise throwing an error to the nearest surrounding Enclose.
ConfirmBy[expr,f,info]
evaluates info and includes its value in the thrown error if expr is not confirmed.
ConfirmBy[expr,f,info,tag]
uses the specified tag for any thrown errors.
Details
- ConfirmBy[expr,…] returns expr if expr is successfully confirmed.
- ConfirmBy is dynamically scoped when given a tag. Otherwise, it is lexically scoped. »
- The default value of info is Null.
- Failure objects generated by ConfirmBy include the following fields:
-
"Information" info from ConfirmBy[expr,f,info,…] "Expression" expr from ConfirmBy[expr,…] "Function" f from ConfirmBy[expr,f,…] - Values of these fields can be extracted using failure["prop"] or directly through Enclose[expr,"prop"].
Examples
open allclose allBasic Examples (2)
Scope (3)
Properties & Relations (1)
ConfirmBy can be emulated with ConfirmMatch:
Text
Wolfram Research (2020), ConfirmBy, Wolfram Language function, https://reference.wolfram.com/language/ref/ConfirmBy.html.
CMS
Wolfram Language. 2020. "ConfirmBy." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ConfirmBy.html.
APA
Wolfram Language. (2020). ConfirmBy. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ConfirmBy.html