How to get frame around every function without any evaluation?
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
Is there a good universal method that allows the making of a frame around every function. In the output, functions should remain unchanged (no evaluation, or any other changes) and each function should have frame.
For example, to make the frame around Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]
something like MakeNiceFrames[Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]]
. An output should look exactly same as in input Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]
with every function (including head and closing bracket) separately framed.
It will be nice to have that kind of framing for visual separations of functions while debugging. I have experimented with Framed
. But each function needs the use of separate Framed
function and functions are actually evaluated, what makes it makes inconvenient to use.
debugging frame
add a comment |Â
up vote
2
down vote
favorite
Is there a good universal method that allows the making of a frame around every function. In the output, functions should remain unchanged (no evaluation, or any other changes) and each function should have frame.
For example, to make the frame around Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]
something like MakeNiceFrames[Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]]
. An output should look exactly same as in input Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]
with every function (including head and closing bracket) separately framed.
It will be nice to have that kind of framing for visual separations of functions while debugging. I have experimented with Framed
. But each function needs the use of separate Framed
function and functions are actually evaluated, what makes it makes inconvenient to use.
debugging frame
Related: 15516.
â Kubaâ¦
3 hours ago
1
For formal clarity you should specify if you need framed function together with all its arguments or just the function's name framed (i suspect the former). A side note: triple-click any function name (Head) and it will be selected from Head start to the closing bracket. Perhaps somehow useful for this problem if you don't want to have too many frames, which could be confusing.
â Vitaliy Kaurov
3 hours ago
@VitaliyKaurov First assumption is right. I edited question and part of it looks as "An output should look exactly same as in inputPlus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]
with every function (including head and closing bracket) separately framed." Do you think anything other should be added?
â vasili111
3 hours ago
1
TreeForm[Hold[ Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]] ]]
meets the use case in a different (and possibly more useful) way.
â Alan
1 hour ago
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
Is there a good universal method that allows the making of a frame around every function. In the output, functions should remain unchanged (no evaluation, or any other changes) and each function should have frame.
For example, to make the frame around Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]
something like MakeNiceFrames[Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]]
. An output should look exactly same as in input Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]
with every function (including head and closing bracket) separately framed.
It will be nice to have that kind of framing for visual separations of functions while debugging. I have experimented with Framed
. But each function needs the use of separate Framed
function and functions are actually evaluated, what makes it makes inconvenient to use.
debugging frame
Is there a good universal method that allows the making of a frame around every function. In the output, functions should remain unchanged (no evaluation, or any other changes) and each function should have frame.
For example, to make the frame around Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]
something like MakeNiceFrames[Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]]
. An output should look exactly same as in input Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]
with every function (including head and closing bracket) separately framed.
It will be nice to have that kind of framing for visual separations of functions while debugging. I have experimented with Framed
. But each function needs the use of separate Framed
function and functions are actually evaluated, what makes it makes inconvenient to use.
debugging frame
debugging frame
edited 3 hours ago
asked 4 hours ago
vasili111
25317
25317
Related: 15516.
â Kubaâ¦
3 hours ago
1
For formal clarity you should specify if you need framed function together with all its arguments or just the function's name framed (i suspect the former). A side note: triple-click any function name (Head) and it will be selected from Head start to the closing bracket. Perhaps somehow useful for this problem if you don't want to have too many frames, which could be confusing.
â Vitaliy Kaurov
3 hours ago
@VitaliyKaurov First assumption is right. I edited question and part of it looks as "An output should look exactly same as in inputPlus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]
with every function (including head and closing bracket) separately framed." Do you think anything other should be added?
â vasili111
3 hours ago
1
TreeForm[Hold[ Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]] ]]
meets the use case in a different (and possibly more useful) way.
â Alan
1 hour ago
add a comment |Â
Related: 15516.
â Kubaâ¦
3 hours ago
1
For formal clarity you should specify if you need framed function together with all its arguments or just the function's name framed (i suspect the former). A side note: triple-click any function name (Head) and it will be selected from Head start to the closing bracket. Perhaps somehow useful for this problem if you don't want to have too many frames, which could be confusing.
â Vitaliy Kaurov
3 hours ago
@VitaliyKaurov First assumption is right. I edited question and part of it looks as "An output should look exactly same as in inputPlus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]
with every function (including head and closing bracket) separately framed." Do you think anything other should be added?
â vasili111
3 hours ago
1
TreeForm[Hold[ Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]] ]]
meets the use case in a different (and possibly more useful) way.
â Alan
1 hour ago
Related: 15516.
â Kubaâ¦
3 hours ago
Related: 15516.
â Kubaâ¦
3 hours ago
1
1
For formal clarity you should specify if you need framed function together with all its arguments or just the function's name framed (i suspect the former). A side note: triple-click any function name (Head) and it will be selected from Head start to the closing bracket. Perhaps somehow useful for this problem if you don't want to have too many frames, which could be confusing.
â Vitaliy Kaurov
3 hours ago
For formal clarity you should specify if you need framed function together with all its arguments or just the function's name framed (i suspect the former). A side note: triple-click any function name (Head) and it will be selected from Head start to the closing bracket. Perhaps somehow useful for this problem if you don't want to have too many frames, which could be confusing.
â Vitaliy Kaurov
3 hours ago
@VitaliyKaurov First assumption is right. I edited question and part of it looks as "An output should look exactly same as in input
Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]
with every function (including head and closing bracket) separately framed." Do you think anything other should be added?â vasili111
3 hours ago
@VitaliyKaurov First assumption is right. I edited question and part of it looks as "An output should look exactly same as in input
Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]
with every function (including head and closing bracket) separately framed." Do you think anything other should be added?â vasili111
3 hours ago
1
1
TreeForm[Hold[ Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]] ]]
meets the use case in a different (and possibly more useful) way.â Alan
1 hour ago
TreeForm[Hold[ Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]] ]]
meets the use case in a different (and possibly more useful) way.â Alan
1 hour ago
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
3
down vote
I don't know how useful this construct would be, but one idea is to use Inactivate
:
ReplaceRepeated[
Inactivate[Plus[1,Plus[Plus[1,1],Plus[Plus[1,1],1]]]],
Inactive[h_][a___] :> Framed[HoldForm[h][a]]
]
1
Could you please add howInactivate
,HoldForm
andHold
differ. This seems to enable much shorter code than mine.
â Johu
58 mins ago
add a comment |Â
up vote
2
down vote
But each function needs the use of separate Framed function
Will solve it by using RuleDelayed
and Replace
with levelspec.
and functions are actually evaluated, what makes it makes inconvenient to use.
Will keep it from evaluating using Hold
.
f = Hold[Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]];
Replace[f, z_ :> Framed[z], 2, -1]
And my attempt to keep the head from evaluating
f = Hold[Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]];
Replace[f,
z : h_[args___] :> Row[h, Framed[Row[args, ","]]], 1, -1][[1]]
Replace[f,
h_[args___] :>
Row[h, "[", Row[args, ","], "]", Frame -> True], 1, -1][[1]]
To be honest, I was amazed when I learned z:h_
kind of syntax. You can understand how it works, if you read carefully the description part of Pattern
.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
I don't know how useful this construct would be, but one idea is to use Inactivate
:
ReplaceRepeated[
Inactivate[Plus[1,Plus[Plus[1,1],Plus[Plus[1,1],1]]]],
Inactive[h_][a___] :> Framed[HoldForm[h][a]]
]
1
Could you please add howInactivate
,HoldForm
andHold
differ. This seems to enable much shorter code than mine.
â Johu
58 mins ago
add a comment |Â
up vote
3
down vote
I don't know how useful this construct would be, but one idea is to use Inactivate
:
ReplaceRepeated[
Inactivate[Plus[1,Plus[Plus[1,1],Plus[Plus[1,1],1]]]],
Inactive[h_][a___] :> Framed[HoldForm[h][a]]
]
1
Could you please add howInactivate
,HoldForm
andHold
differ. This seems to enable much shorter code than mine.
â Johu
58 mins ago
add a comment |Â
up vote
3
down vote
up vote
3
down vote
I don't know how useful this construct would be, but one idea is to use Inactivate
:
ReplaceRepeated[
Inactivate[Plus[1,Plus[Plus[1,1],Plus[Plus[1,1],1]]]],
Inactive[h_][a___] :> Framed[HoldForm[h][a]]
]
I don't know how useful this construct would be, but one idea is to use Inactivate
:
ReplaceRepeated[
Inactivate[Plus[1,Plus[Plus[1,1],Plus[Plus[1,1],1]]]],
Inactive[h_][a___] :> Framed[HoldForm[h][a]]
]
answered 1 hour ago
Carl Woll
57.2k273149
57.2k273149
1
Could you please add howInactivate
,HoldForm
andHold
differ. This seems to enable much shorter code than mine.
â Johu
58 mins ago
add a comment |Â
1
Could you please add howInactivate
,HoldForm
andHold
differ. This seems to enable much shorter code than mine.
â Johu
58 mins ago
1
1
Could you please add how
Inactivate
, HoldForm
and Hold
differ. This seems to enable much shorter code than mine.â Johu
58 mins ago
Could you please add how
Inactivate
, HoldForm
and Hold
differ. This seems to enable much shorter code than mine.â Johu
58 mins ago
add a comment |Â
up vote
2
down vote
But each function needs the use of separate Framed function
Will solve it by using RuleDelayed
and Replace
with levelspec.
and functions are actually evaluated, what makes it makes inconvenient to use.
Will keep it from evaluating using Hold
.
f = Hold[Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]];
Replace[f, z_ :> Framed[z], 2, -1]
And my attempt to keep the head from evaluating
f = Hold[Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]];
Replace[f,
z : h_[args___] :> Row[h, Framed[Row[args, ","]]], 1, -1][[1]]
Replace[f,
h_[args___] :>
Row[h, "[", Row[args, ","], "]", Frame -> True], 1, -1][[1]]
To be honest, I was amazed when I learned z:h_
kind of syntax. You can understand how it works, if you read carefully the description part of Pattern
.
add a comment |Â
up vote
2
down vote
But each function needs the use of separate Framed function
Will solve it by using RuleDelayed
and Replace
with levelspec.
and functions are actually evaluated, what makes it makes inconvenient to use.
Will keep it from evaluating using Hold
.
f = Hold[Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]];
Replace[f, z_ :> Framed[z], 2, -1]
And my attempt to keep the head from evaluating
f = Hold[Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]];
Replace[f,
z : h_[args___] :> Row[h, Framed[Row[args, ","]]], 1, -1][[1]]
Replace[f,
h_[args___] :>
Row[h, "[", Row[args, ","], "]", Frame -> True], 1, -1][[1]]
To be honest, I was amazed when I learned z:h_
kind of syntax. You can understand how it works, if you read carefully the description part of Pattern
.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
But each function needs the use of separate Framed function
Will solve it by using RuleDelayed
and Replace
with levelspec.
and functions are actually evaluated, what makes it makes inconvenient to use.
Will keep it from evaluating using Hold
.
f = Hold[Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]];
Replace[f, z_ :> Framed[z], 2, -1]
And my attempt to keep the head from evaluating
f = Hold[Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]];
Replace[f,
z : h_[args___] :> Row[h, Framed[Row[args, ","]]], 1, -1][[1]]
Replace[f,
h_[args___] :>
Row[h, "[", Row[args, ","], "]", Frame -> True], 1, -1][[1]]
To be honest, I was amazed when I learned z:h_
kind of syntax. You can understand how it works, if you read carefully the description part of Pattern
.
But each function needs the use of separate Framed function
Will solve it by using RuleDelayed
and Replace
with levelspec.
and functions are actually evaluated, what makes it makes inconvenient to use.
Will keep it from evaluating using Hold
.
f = Hold[Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]];
Replace[f, z_ :> Framed[z], 2, -1]
And my attempt to keep the head from evaluating
f = Hold[Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]];
Replace[f,
z : h_[args___] :> Row[h, Framed[Row[args, ","]]], 1, -1][[1]]
Replace[f,
h_[args___] :>
Row[h, "[", Row[args, ","], "]", Frame -> True], 1, -1][[1]]
To be honest, I was amazed when I learned z:h_
kind of syntax. You can understand how it works, if you read carefully the description part of Pattern
.
edited 2 hours ago
answered 3 hours ago
Johu
3,0661033
3,0661033
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f182056%2fhow-to-get-frame-around-every-function-without-any-evaluation%23new-answer', 'question_page');
);
Post as a guest
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
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
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
Related: 15516.
â Kubaâ¦
3 hours ago
1
For formal clarity you should specify if you need framed function together with all its arguments or just the function's name framed (i suspect the former). A side note: triple-click any function name (Head) and it will be selected from Head start to the closing bracket. Perhaps somehow useful for this problem if you don't want to have too many frames, which could be confusing.
â Vitaliy Kaurov
3 hours ago
@VitaliyKaurov First assumption is right. I edited question and part of it looks as "An output should look exactly same as in input
Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]]
with every function (including head and closing bracket) separately framed." Do you think anything other should be added?â vasili111
3 hours ago
1
TreeForm[Hold[ Plus[1, Plus[Plus[1, 1], Plus[Plus[1, 1], 1]]] ]]
meets the use case in a different (and possibly more useful) way.â Alan
1 hour ago