Jump to content

Symmetric difference: Difference between revisions

Demonstrating Object Pascal's 'symmetric difference' operator
(Demonstrating Delphi/Object Pascal's 'symmetric difference' operator)
(Demonstrating Object Pascal's 'symmetric difference' operator)
Line 2,686:
ListA - ListB -> Serena
ListB - ListA -> Jim</pre>
Object Pascal actually has a 'Symmetric Difference' operator `> <`:
<syntaxhighlight lang="pascal">
program SymmetricDifference;
 
type
charSet = set of Char;
 
var
s1, s2, s3: charSet;
ch: char;
 
begin
s1 := ['a', 'b', 'c', 'd'];
s2 := ['c', 'd', 'e', 'f'];
s3 := s1 >< s2;
 
for ch in s3 do
write(ch, ' ');
writeLn;
end.
</syntaxhighlight>
Output:
<pre>
a b e f
</pre>
 
=={{header|Perl}}==
57

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.