Van Eck sequence: Difference between revisions
Content added Content deleted
(→{{header|Vlang}}: Rename "Vlang" in "V (Vlang)") |
|||
Line 2,977: | Line 2,977: | ||
say 'terms ' LO " through " HI ' of the Van Eck sequence are: ' out</syntaxhighlight> |
say 'terms ' LO " through " HI ' of the Van Eck sequence are: ' out</syntaxhighlight> |
||
{{out|output|text= is identical to the 1<sup>st</sup> REXX version.}} <br><br> |
{{out|output|text= is identical to the 1<sup>st</sup> REXX version.}} <br><br> |
||
=={{header|RPL}}== |
|||
{{works with|Halcyon Calc|4.2.7}} |
|||
{| class="wikitable" |
|||
! RPL code |
|||
! Comment |
|||
|- |
|||
| |
|||
≪ |
|||
DUP DUP SIZE GET → list item |
|||
≪ list SIZE 1 - DUP 1 CF |
|||
'''WHILE''' DUP 1 FC? AND '''REPEAT ''' |
|||
'''IF''' list OVER GET item == '''THEN''' 1 SF '''END''' |
|||
1 - '''END ''' |
|||
- 1 FS? * |
|||
≫ ≫ ''''LastOcc'''' STO |
|||
≪ { 0 } 2 ROT '''START''' DUP '''LastOcc''' + '''NEXT''' |
|||
≫ ''''VANECK'''' STO |
|||
≪ |
|||
OVER SIZE { } ROT ROT '''FOR''' j |
|||
OVER j GET + '''NEXT''' |
|||
SWAP DROP |
|||
≫ ''''LASTL'''' STO |
|||
| |
|||
''( { sequence } -- pos_from_end )'' |
|||
Store sequence and last item |
|||
Initialize loop |
|||
Scan sequence backwards |
|||
if item found then break |
|||
decrement |
|||
Return pos or 0 if not found |
|||
''( n -- { 0..VanEck(n) } )'' |
|||
''( { n items } m -- { m..n } )'' |
|||
Extract items from mth position |
|||
|} |
|||
{{in}} |
|||
<pre> |
|||
10 VANECK |
|||
1000 VANECK |
|||
991 LASTL |
|||
</pre> |
|||
{{out}} |
|||
<pre> |
|||
2: { 0 0 1 0 2 0 2 2 1 6 } |
|||
1: { 4 7 30 25 67 225 488 0 10 136 } |
|||
</pre> |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |