Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.4K Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Help redefining the output suppression key ";"

Posted 4 years ago
POSTED BY: Isaac Avery
4 Replies
Posted 4 years ago

Could you possibly give an example of how I would go about evaluating an expression to Null?

Yeah, use CompoundExpression where the last element is Null:

CompoundExpression[
    data = {1,3,6,5,3,3,6},
    Print["Median: ", Median[data]],
    Null
]

You're talking about using ; for something else, which I don't want to know anything about because it sounds pretty shady, so I used the explicit function call version of CompoundExpression.

Or alternatively, can you tell me which system file assigns the semicolon to be that infix operator shortcut that you described?

This is not a thing. This behavior is compiled into the WL language interpreter for how it responds to an EnterExpressionPacket (the MathLink/WSTP packet type that handles the In[1] read-eval-print loop). In other words, like most of the system it's not available in source form in the product.

POSTED BY: Joel Klein
Posted 4 years ago

Ok I see.

Well thank you for the information and help on how to implement the Null output using the CompoundExpression.

POSTED BY: Isaac Avery
Posted 4 years ago

Actually, any expression evaluating to Null will result in no Output cell being created.

If you look at FullForm[Hold[expr;]] you'll see this as CompoundExpression[expr, Null]. In other words, semicolon (;) is actually an infix operator for CompoundExpression, and if you don't provide an expression on its right side, a Null is substituted, and voila, no output.

So, to suppress output, evaluate to Null.

POSTED BY: Joel Klein
Posted 4 years ago

Thanks, that's so interesting.

Could you possibly give an example of how I would go about evaluating an expression to Null?

I'm not very good with the Wolfram syntax, so for example if my expression was

n = 2

How could I evaluate that cell and not get any output printed?

Or alternatively, can you tell me which system file assigns the semicolon to be that infix operator shortcut that you described?

POSTED BY: Isaac Avery
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard