RosettaCodeData/Task/Remove-duplicate-elements/Lambdatalk/remove-duplicate-elements.l...

18 lines
457 B
Plaintext

{def removedup
{def removedup.loop
{lambda {:a :b}
{if {A.empty? :a}
then :b
else {removedup.loop {A.rest :a}
{if {= {A.in? {A.first :a} :b} -1}
then {A.addlast! {A.first :a} :b}
else :b}}}}}
{lambda {:s}
{S.replace (\[|\]|,) by space in
{A.disp
{removedup.loop {A.new :s} {A.new}}}}}}
-> removedup
{removedup 1 2 3 a b c 2 3 4 b c d}
-> 1 2 3 a b c 4 d