Wolfram Research

Function Repository Resource:

Terse

Source Notebook

An operator form of Short

Contributed by: Seth J. Chandler

ResourceFunction["Terse"][n]

gives an operator form of Short that will shorten the expression it is passed to approximately n lines.

Examples

Basic Examples

Output a short form of 100,000 integers in 5 lines:

In[1]:=
Range[100000] // ResourceFunction["Terse"][5]
Out[1]=

Output a short form of 100,000 integers, usually in a line or two:

In[2]:=
Range[100000] // ResourceFunction["Terse"][]
Out[2]=

Scope

A prefix form of the Terse operator:

In[3]:=
ResourceFunction["Terse"][][Range[100]]
Out[3]=

An infix form of the Terse operator:

In[4]:=
Range[100]~ResourceFunction["Terse"]~3
Out[4]=

Applications

Using Terse in composition with other operators can shorten output, as shown in the following comparison:

In[5]:=
{GroupBy[EvenQ][
  Range[100]], (GroupBy[EvenQ] /* ResourceFunction["Terse"][3])[
  Range[100]]}
Out[5]=

Properties and Relations

An idea behind Terse, illustrated by a comparison of the expressions in the following list, is that it is less distracting than starting code with Short or a postfix form of something like Short[#,5]&:

In[6]:=
{(range = Range[100000]) // Short[#, 5] &, Short[range = Range[100000], 5], (range = Range[100000]) // ResourceFunction["Terse"][5]};

Possible Issues

Terse is like Short in that it requires parentheses surrounding the assignment in the following code if the intent is to let the variable range hold Range[100000] rather than its Short form:

In[7]:=
range = Range[100000] // ResourceFunction["Terse"][5];
{range === Range[100000], range === Short[Range[100000], 5]}
Out[8]=

Resource History

License Information