43 lines
1.3 KiB
Plaintext
43 lines
1.3 KiB
Plaintext
redim shared as string Result(-1) 'represent our sets as strings;
|
|
'this'll do to illustrate the concept
|
|
|
|
sub sym( A() as string, B() as string )
|
|
dim as integer ai, bi, ri
|
|
dim as boolean add_it
|
|
for ai = lbound(A) to ubound(A)
|
|
add_it = true
|
|
for bi = lbound(B) to ubound(B)
|
|
if A(ai) = B(bi) then
|
|
add_it=false
|
|
exit for 'if item is common to both lists, don't include it
|
|
end if
|
|
next bi
|
|
if add_it then
|
|
for ri = 0 to ubound(Result)
|
|
if A(ai) = Result(ri) then
|
|
add_it=false
|
|
exit for
|
|
'if item is already in the result, don't include it again
|
|
end if
|
|
next ri
|
|
end if
|
|
if add_it then
|
|
redim preserve as string Result(0 to ubound(Result)+1)
|
|
Result(ubound(Result)) = A(ai)
|
|
end if
|
|
|
|
next ai
|
|
end sub
|
|
|
|
dim as string A(0 to 3) = {"John", "Bob", "Mary", "Serena"}
|
|
dim as string B(0 to 4) = {"Jim", "Mary", "John", "Bob", "Jim"}
|
|
'contains a double to show code can handle it
|
|
|
|
|
|
sym(A(), B())
|
|
sym(B(), A())
|
|
|
|
for i as uinteger = 0 to ubound(Result)
|
|
print Result(i)
|
|
next i
|