Sver
Full Member
Posts: 145
|
Post by Sver on Oct 4, 2019 4:30:54 GMT -5
x=5
dim s$(x) s$(1)="bas" :s$(2)="Toos" :s$(3)="kees" :s$(4)="Kees" :s$(5)="bas" '---------------------------------
for i=1 to x-1 for s=i+1 to x if lower$(s$(i))=lower$(s$(s)) then s$(i)="" 'remove 1e next s next i '-------------------------------------- sort s$() ,1,x '--------------------------------------
for d=1 to x if s$(d)<>"" then print s$(d) next d
|
|
|
Post by tsh73 on Oct 4, 2019 13:31:49 GMT -5
A bit shorter? (really, SORT does lot's of work, and does it fast)
x=5 dim s$(x) s$(1)="bas" :s$(2)="Toos" :s$(3)="kees" :s$(4)="Kees" :s$(5)="bas" '--------------------------------- sort s$() ,1,x '--------------------------------- print s$(1) for d=2 to x if s$(d)<>s$(d-1) then print s$(d) next d
|
|
Sver
Full Member
Posts: 145
|
Post by Sver on Oct 5, 2019 0:16:36 GMT -5
Thanks tsh73, If it works we can choose between: First program: Slow , keep it's ranking (sort is a option after it, we can see the item added latest) Second programm, Fast, losing ranking (when it isn't important) but i changed the items. (kees, kees, Kees). Expected one kees and one Kees, but not three. Tricky:
x=5 dim s$(x) s$(1)="bas" :s$(2)="kees" :s$(3)="kees" :s$(4)="Kees" :s$(5)="bas" '--------------------------------- sort s$() ,1,x '--------------------------------- 'print s$(1) 'print s$(2) 'print s$(3) 'print s$(4) 'print s$(5) print
print s$(1) for d=2 to x if s$(d)<>s$(d-1) then print s$(d) next d
,.....and no remove in the array.
|
|
|
Post by tsh73 on Oct 5, 2019 7:02:51 GMT -5
Sorry. SORT does not distinguish letter case. So for it, (kees, Kees) are actually the same. We can change comparison to
if lower$(s$(d))<>lower$(s$(d-1)) then print s$(d)
but then all we'll get is
bas kees (it could be Kees as well - but only one of the two).
|
|