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 (2) 

Output a short form of 100,000 integers in five 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 (2) 

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 (1) 

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

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

Properties and Relations (1) 

An idea behind Terse, illustrated by a comparison of the expressions in the List below, 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]}
Out[6]=

Possible Issues (1) 

Terse is like Short in that it requires parentheses surrounding the assignment in the code below 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]
Out[7]=
In[8]:=
{range === Range[100000], range === Short[Range[100000], 5]}
Out[8]=

Publisher

Seth J. Chandler

Version History

  • 1.0.0 – 24 June 2019

License Information