Difference between revisions of "Sequence"

From NARS2000
Jump to navigationJump to search
m
 
Line 26: Line 26:
 
<p>For example</p>
 
<p>For example</p>
  
<apll>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3..10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</apll>Start and end values<br />
+
<apll><pre>
<apll>3 4 5 6 7 8 9 10<br />
+
      3..10       Start and end values
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3 2..10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</apll>Start, step, and end values<br />
+
3 4 5 6 7 8 9 10
<apll>3 5 7 9<br />
+
      3 2..10     Start, step, and end values
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(⊂3 4)..6&nbsp;&nbsp;&nbsp;&nbsp;</apll>Two start values, so the result is two-dimensional and nested<br />
+
3 5 7 9
<apll>&nbsp;3 4 &nbsp;3 5 &nbsp;3 6 <br />
+
      (⊂3 4)..6   Two start values, so the result is two-dimensional and nested
&nbsp;4 4 &nbsp;4 5 &nbsp;4 6 <br />
+
3 4 3 5 3 6  
&nbsp;5 4 &nbsp;5 5 &nbsp;5 6 <br />
+
4 4 4 5 4 6  
&nbsp;6 4 &nbsp;6 5 &nbsp;6 6 <br />
+
5 4 5 5 5 6  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3..⊂5 6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</apll>Two ending values, so the result is two-dimensional and nested<br />
+
6 4 6 5 6 6  
<apll>&nbsp;3 3 &nbsp;3 4 &nbsp;3 5 &nbsp;3 6 <br />
+
      3..⊂5 6     Two ending values, so the result is two-dimensional and nested
&nbsp;4 3 &nbsp;4 4 &nbsp;4 5 &nbsp;4 6 <br />
+
3 3 3 4 3 5 3 6  
&nbsp;5 3 &nbsp;5 4 &nbsp;5 5 &nbsp;5 6 <br />
+
4 3 4 4 4 5 4 6  
</apll>
+
5 3 5 4 5 5 5 6  
 +
</pre></apll>
  
 
<p>The starting value(s) may be greater than the ending values in which case the sequence is in descending order.  The sign of the optional step value is ignored.</p>
 
<p>The starting value(s) may be greater than the ending values in which case the sequence is in descending order.  The sign of the optional step value is ignored.</p>
  
<apll>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(6 7)2..2<br />
+
<apll><pre>
&nbsp;6 7 &nbsp;6 5 &nbsp;6 3 <br />
+
      (6 7)2..2
&nbsp;4 7 &nbsp;4 5 &nbsp;4 3 <br />
+
6 7 6 5 6 3
&nbsp;2 7 &nbsp;2 5 &nbsp;2 3 <br />
+
4 7 4 5 4 3
</apll>
+
2 7 2 5 2 3
 +
</pre></apll>
  
 
<p>This primitive was suggested by John Scholes of Dyalog, Ltd.</p>
 
<p>This primitive was suggested by John Scholes of Dyalog, Ltd.</p>

Latest revision as of 23:18, 15 April 2018

Z←L..R returns an array consisting of the numeric sequence of values between L and R.
L is a numeric or nested scalar or one- or two-element vector consisting of starting value(s) and optional step value(s) (default is 1) for the sequence.
R is a numeric or nested scalar or one-element vector consisting of ending value(s) for the sequence.
Z is an array whose values represent the sequence of values between L and R.


For example

      3..10        Start and end values
3 4 5 6 7 8 9 10
      3 2..10      Start, step, and end values
3 5 7 9
      (⊂3 4)..6    Two start values, so the result is two-dimensional and nested
 3 4  3 5  3 6 
 4 4  4 5  4 6 
 5 4  5 5  5 6 
 6 4  6 5  6 6 
      3..⊂5 6      Two ending values, so the result is two-dimensional and nested
 3 3  3 4  3 5  3 6 
 4 3  4 4  4 5  4 6 
 5 3  5 4  5 5  5 6 

The starting value(s) may be greater than the ending values in which case the sequence is in descending order. The sign of the optional step value is ignored.

      (6 7)2..2
 6 7  6 5  6 3
 4 7  4 5  4 3
 2 7  2 5  2 3

This primitive was suggested by John Scholes of Dyalog, Ltd.