Basic Examples
Basic Examples
Output a short form of 100,000 integers in 5 lines:
Range[100000]//
[5]
In[]:=
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,99928,99965,99966,99967,99968,99969,99970,99971,99972,99973,99974,99975,99976,99977,99978,99979,99980,99981,99982,99983,99984,99985,99986,99987,99988,99989,99990,99991,99992,99993,99994,99995,99996,99997,99998,99999,100000}
Out[]//Short=
Output a short form of 100, 000 integers, usually in a line or two:
Range[100000]//
[]
In[]:=
{1,2,3,4,5,6,7,8,9,99982,99992,99993,99994,99995,99996,99997,99998,99999,100000}
Out[]//Short=
Scope
Scope
A prefix form of the Terse operator:
[][Range[100]]
In[]:=
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,72,87,88,89,90,91,92,93,94,95,96,97,98,99,100}
Out[]//Short=
An infix form of the Terse operator:
Range[100]~
~3
In[]:=
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,36,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100}
Out[]//Short=
Applications
Applications
Using Terse in composition with other operators can shorten output, as shown in the comparison below :
GroupBy[EvenQ][Range[100]],GroupBy[EvenQ]/*
[3][Range[100]]
In[]:=
{False{1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99},True{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100},False{1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99},True{2,4,6,8,42,94,96,98,100}}
Out[]=
Properties and Relations
Properties and Relations
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 or a postfix form of something like [#,5]&:
(range=Range[100000])//Short[#,5]&,Short[range=Range[100000],5],(range=Range[100000])//
[5];
In[]:=
Possible Issues
Possible Issues
Terse is like in that it requires parentheses surrounding the assignment in the code below if the intent is to let the variable range hold [100000] rather than its form:
range=Range[100000]//
[5];{range===Range[100000],range===Short[Range[100000],5]}
In[]:=
{False,True}
Out[]=