RosettaCodeData/Task/Remove-duplicate-elements/BBC-BASIC/remove-duplicate-elements.b...

22 lines
563 B
Plaintext

DIM list$(15)
list$() = "Now", "is", "the", "time", "for", "all", "good", "men", \
\ "to", "come", "to", "the", "aid", "of", "the", "party."
num% = FNremoveduplicates(list$())
FOR i% = 0 TO num%-1
PRINT list$(i%) " " ;
NEXT
PRINT
END
DEF FNremoveduplicates(l$())
LOCAL i%, j%, n%, i$
n% = 1
FOR i% = 1 TO DIM(l$(), 1)
i$ = l$(i%)
FOR j% = 0 TO i%-1
IF i$ = l$(j%) EXIT FOR
NEXT
IF j%>=i% l$(n%) = i$ : n% += 1
NEXT
= n%