Remove duplicate elements: Difference between revisions

add RPL
(Jakt)
(add RPL)
Line 4,457:
<pre>
Now is the time for all good men to come aid of party.
</pre>
 
=={{header|RPL}}==
We follow here a fourth way, which requires few words and take advantage of the (relative) speed of the <code>POS</code> function.
{{works with|Halcyon Calc|4.2.8}}
{| class="wikitable"
! RPL code
! Comment
|-
|
≪ → input
≪ { }
1 input SIZE '''FOR''' j
input j GET
'''IF''' DUP2 POS '''THEN''' DROP '''ELSE''' + '''END '''
'''NEXT'''
≫ ≫ ‘'''NODUP'''’ STO
|
'''NODUP''' ''( { a b a...c } -- { a b..c } ) ''
Initialize output list
Go through input list
If input[j] already in output list
then forget it else add it to output list
End loop
|}
{ 1 2 3 'a' 'b' 'c' 2 3 4 'b' 'c' 'd' } '''NODUP'''
{{out}}
<pre>
1: { 1 2 3 'a' 'b' 'c' 4 'd' }
</pre>
 
1,150

edits