Filter: Difference between revisions

1,182 bytes added ,  1 year ago
add RPL
(→‎Joy: add)
(add RPL)
Line 3,395:
return bArray
</syntaxhighlight>
 
=={{header|RPL}}==
There is no library concept in RPL. However, in 1990, Jan Christiaan van Winkel proposed to the RPL community a way to get something close.
Assuming the programs frequently needed are stored in a specific directory named <code>MyLib</code> located at root directory, the following program, also located at the root directory, can be invoked by any program to access one of the library features.
{{works with|Halcyon Calc|4.2.7}}
{| class="wikitable"
! RPL code
! Comment
|-
|
DUP SIZE {} 2 ROT '''FOR''' j OVER j GET + 2 '''STEP'''
≫ ''''FILTR'''' STO
LIST→ → len
≪ {} len 1 '''FOR''' j
'''IF''' j 2 MOD '''THEN''' SWAP DROP '''ELSE''' + '''END'''
-1 '''STEP'''
≫ ≫ ''''FILTD'''' STO
|
'''FILTR''' ''( { a1 a2.. an } -- { a1 a2.. an } { a2 a4... a2k } )''
selective copy
'''FILTD''' ''( { a1 a2.. an } -- { a2 a4... a2k } )''
Destructive version : put the array in the stack...
... and make a new one by picking one out of two items
|}
{{in}}
<pre>
{ 1 2 3 4 5 6 7 8 9 } FILTR
{ 1 2 3 4 5 6 7 8 9 } FILTD
</pre>
{{out}}
<pre>
3: { 1 2 3 4 5 6 7 8 9 }
2: { 2 4 6 8 }
1: { 2 4 6 8 }
</pre>
 
=={{header|Ruby}}==
1,150

edits