RosettaCodeData/Task/Remove-duplicate-elements/Forth/remove-duplicate-elements-2.fth

13 lines
225 B
Forth
Raw Permalink Normal View History

2013-04-10 23:57:08 -07:00
: uniqv { a n \ r e -- n }
a n cells+ to e
a dup to r
\ the write address lives on the stack
begin
r e <
while
r @ over !
r cell+ e skip-dups to r
cell+
repeat
a - cell / ;