Is there a builtin function to turn selective Echos off?Metaquestion: how to find out why (e.g.) MatchQ[42,...
Manager encourages me to take day of sick leave instead of PTO, what's in it for him?
GitHub repo with Apache License version 2 in package.json, but no full license copy nor comment headers
Are actors contractually obligated to certain things like going nude/ Sensual Scenes/ Gory Scenes?
What do these pins mean? Where should I plug them in?
How to fix folder structure in Windows 7 and 10
US entry with tourist visa but past alcohol arrest
Is there any actual security benefit to restricting foreign IPs?
How is the problem, {⟨G⟩|G has no triangle} in Logspace?
Can one guy with a duplicator initiate a nuclear apocalypse?
Why are some of the Stunts in The Expanse RPG labelled 'Core'?
How is underwater propagation of sound possible?
How does one calculate the distribution of the Matt Colville way of rolling stats?
CDG baggage claim before or after immigration?
The 100 soldier problem
What was the deeper meaning of Hermione wanting the cloak?
Why NASA publish all the results/data it gets?
Is the sentence "何でも忘れた" correct?
How to create a grid following points in QGIS?
Debussy as term for bathroom?
How to deal with my team leader who keeps calling me about project updates even though I am on leave for personal reasons?
How to ask a man to not take up more than one seat on public transport while avoiding conflict?
What do solvers like Gurobi and CPLEX do when they run into hard instances of MIP
I reverse the source code, you negate the input!
Where are they calling from?
Is there a builtin function to turn selective Echos off?
Metaquestion: how to find out why (e.g.) MatchQ[42, _?Function[x, True]] is False?How to find the name of the current function?Is there a way to find out who is importing a package?Is there a way to accelerate buffering to the screen?Using Dialog inside a function to debugHow to get frame around every function without any evaluation?Force a function to report argument type mismatchesPlotting intermediate values of an argument in a recursive function
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
$begingroup$
Suppose I have a code block
EchoOff[CompoundExpression[
...,
Echo[...,"echo 1",f],
Echo[...,"echo 2",g],
...
]]
Is there a function EchoOff that can be wrapped around an expression to turn off the output of all Echo encountered?
Moreover is there something like turning selective echos off? For example,
EchoOff[expr,{1,4}] turns off the first and fourth Echo encountered in the expression.
Or simply if the Echo can be marked as 1,2,... and then EchoOff can target them with their mark?
debugging
$endgroup$
add a comment
|
$begingroup$
Suppose I have a code block
EchoOff[CompoundExpression[
...,
Echo[...,"echo 1",f],
Echo[...,"echo 2",g],
...
]]
Is there a function EchoOff that can be wrapped around an expression to turn off the output of all Echo encountered?
Moreover is there something like turning selective echos off? For example,
EchoOff[expr,{1,4}] turns off the first and fourth Echo encountered in the expression.
Or simply if the Echo can be marked as 1,2,... and then EchoOff can target them with their mark?
debugging
$endgroup$
add a comment
|
$begingroup$
Suppose I have a code block
EchoOff[CompoundExpression[
...,
Echo[...,"echo 1",f],
Echo[...,"echo 2",g],
...
]]
Is there a function EchoOff that can be wrapped around an expression to turn off the output of all Echo encountered?
Moreover is there something like turning selective echos off? For example,
EchoOff[expr,{1,4}] turns off the first and fourth Echo encountered in the expression.
Or simply if the Echo can be marked as 1,2,... and then EchoOff can target them with their mark?
debugging
$endgroup$
Suppose I have a code block
EchoOff[CompoundExpression[
...,
Echo[...,"echo 1",f],
Echo[...,"echo 2",g],
...
]]
Is there a function EchoOff that can be wrapped around an expression to turn off the output of all Echo encountered?
Moreover is there something like turning selective echos off? For example,
EchoOff[expr,{1,4}] turns off the first and fourth Echo encountered in the expression.
Or simply if the Echo can be marked as 1,2,... and then EchoOff can target them with their mark?
debugging
debugging
asked 8 hours ago
user13892user13892
1,9887 silver badges19 bronze badges
1,9887 silver badges19 bronze badges
add a comment
|
add a comment
|
2 Answers
2
active
oldest
votes
$begingroup$
You can use GeneralUtilities`DisableEcho:
expr1; Echo[x = 1 + 1];
GeneralUtilities`DisableEcho[ Echo[y = 1 + 2] ; Echo[z = 1 + 3]];Echo[w = 1 + 4]; expr2

z + y
7
$endgroup$
add a comment
|
$begingroup$
ClearAll[EchoOff];
SetAttributes[EchoOff, HoldFirst];
EchoOff[code_] := Block[{Echo},
Echo[c_, bla___] := c;
code
];
Then:
EchoOff[
CompoundExpression[1, Echo[1, "echo 1", f], Echo[2, "echo 2", g], 2]
]
2
You can do that selectively by label with
EchoOff[code_, blacklist_] := Unevaluated[code] /. Table[
With[{label = b},
HoldPattern[Echo[c_, label, bla___]] :> Unevaluated[c]
],
{b, blacklist}
];
EchoOff[
CompoundExpression[1, Echo[1, "echo 1", f], Echo[2, "echo 2", g],
2],
{"echo 1"}
]
echo 2 g[2]
2
$endgroup$
add a comment
|
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "387"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f206446%2fis-there-a-builtin-function-to-turn-selective-echos-off%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
You can use GeneralUtilities`DisableEcho:
expr1; Echo[x = 1 + 1];
GeneralUtilities`DisableEcho[ Echo[y = 1 + 2] ; Echo[z = 1 + 3]];Echo[w = 1 + 4]; expr2

z + y
7
$endgroup$
add a comment
|
$begingroup$
You can use GeneralUtilities`DisableEcho:
expr1; Echo[x = 1 + 1];
GeneralUtilities`DisableEcho[ Echo[y = 1 + 2] ; Echo[z = 1 + 3]];Echo[w = 1 + 4]; expr2

z + y
7
$endgroup$
add a comment
|
$begingroup$
You can use GeneralUtilities`DisableEcho:
expr1; Echo[x = 1 + 1];
GeneralUtilities`DisableEcho[ Echo[y = 1 + 2] ; Echo[z = 1 + 3]];Echo[w = 1 + 4]; expr2

z + y
7
$endgroup$
You can use GeneralUtilities`DisableEcho:
expr1; Echo[x = 1 + 1];
GeneralUtilities`DisableEcho[ Echo[y = 1 + 2] ; Echo[z = 1 + 3]];Echo[w = 1 + 4]; expr2

z + y
7
edited 7 hours ago
answered 7 hours ago
kglrkglr
217k10 gold badges247 silver badges497 bronze badges
217k10 gold badges247 silver badges497 bronze badges
add a comment
|
add a comment
|
$begingroup$
ClearAll[EchoOff];
SetAttributes[EchoOff, HoldFirst];
EchoOff[code_] := Block[{Echo},
Echo[c_, bla___] := c;
code
];
Then:
EchoOff[
CompoundExpression[1, Echo[1, "echo 1", f], Echo[2, "echo 2", g], 2]
]
2
You can do that selectively by label with
EchoOff[code_, blacklist_] := Unevaluated[code] /. Table[
With[{label = b},
HoldPattern[Echo[c_, label, bla___]] :> Unevaluated[c]
],
{b, blacklist}
];
EchoOff[
CompoundExpression[1, Echo[1, "echo 1", f], Echo[2, "echo 2", g],
2],
{"echo 1"}
]
echo 2 g[2]
2
$endgroup$
add a comment
|
$begingroup$
ClearAll[EchoOff];
SetAttributes[EchoOff, HoldFirst];
EchoOff[code_] := Block[{Echo},
Echo[c_, bla___] := c;
code
];
Then:
EchoOff[
CompoundExpression[1, Echo[1, "echo 1", f], Echo[2, "echo 2", g], 2]
]
2
You can do that selectively by label with
EchoOff[code_, blacklist_] := Unevaluated[code] /. Table[
With[{label = b},
HoldPattern[Echo[c_, label, bla___]] :> Unevaluated[c]
],
{b, blacklist}
];
EchoOff[
CompoundExpression[1, Echo[1, "echo 1", f], Echo[2, "echo 2", g],
2],
{"echo 1"}
]
echo 2 g[2]
2
$endgroup$
add a comment
|
$begingroup$
ClearAll[EchoOff];
SetAttributes[EchoOff, HoldFirst];
EchoOff[code_] := Block[{Echo},
Echo[c_, bla___] := c;
code
];
Then:
EchoOff[
CompoundExpression[1, Echo[1, "echo 1", f], Echo[2, "echo 2", g], 2]
]
2
You can do that selectively by label with
EchoOff[code_, blacklist_] := Unevaluated[code] /. Table[
With[{label = b},
HoldPattern[Echo[c_, label, bla___]] :> Unevaluated[c]
],
{b, blacklist}
];
EchoOff[
CompoundExpression[1, Echo[1, "echo 1", f], Echo[2, "echo 2", g],
2],
{"echo 1"}
]
echo 2 g[2]
2
$endgroup$
ClearAll[EchoOff];
SetAttributes[EchoOff, HoldFirst];
EchoOff[code_] := Block[{Echo},
Echo[c_, bla___] := c;
code
];
Then:
EchoOff[
CompoundExpression[1, Echo[1, "echo 1", f], Echo[2, "echo 2", g], 2]
]
2
You can do that selectively by label with
EchoOff[code_, blacklist_] := Unevaluated[code] /. Table[
With[{label = b},
HoldPattern[Echo[c_, label, bla___]] :> Unevaluated[c]
],
{b, blacklist}
];
EchoOff[
CompoundExpression[1, Echo[1, "echo 1", f], Echo[2, "echo 2", g],
2],
{"echo 1"}
]
echo 2 g[2]
2
edited 7 hours ago
answered 7 hours ago
Henrik SchumacherHenrik Schumacher
68.4k5 gold badges98 silver badges190 bronze badges
68.4k5 gold badges98 silver badges190 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f206446%2fis-there-a-builtin-function-to-turn-selective-echos-off%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown