Set: Difference between revisions

1,086 bytes added ,  3 years ago
Added Delphi example
(Undo revision 324759 by Drkameleon (talk))
(Added Delphi example)
Line 1,107:
A is equal to B = false
B is equal to AC = true</pre>
=={{header|Delphi}}==
{{libheader| System.SysUtils}}
{{libheader| Boost.Generics.Collection}}
The library [https://github.com/MaiconSoft/DelphiBoostLib Boost.Generics.Collection].
<lang Delphi>
program Set_task;
 
{$APPTYPE CONSOLE}
 
uses
System.SysUtils,
Boost.Generics.Collection;
 
begin
var s1 := TSet<Integer>.Create([1, 2, 3, 4, 5, 6]);
var s2 := TSet<Integer>.Create([2, 5, 6, 3, 4, 8]);
var s3 := TSet<Integer>.Create([1, 2, 5]);
 
Writeln('S1 ', s1.ToString);
Writeln('S2 ', s2.ToString);
Writeln('S3 ', s3.ToString, #10);
 
Writeln('4 is in S1? ', s1.Has(4));
Writeln('S1 union S2 ', (s1 + S2).ToString);
Writeln('S1 intersection S2 ', (s1 * S2).ToString);
Writeln('S1 difference S2 ', (s1 - S2).ToString);
Writeln('S3 is subset S2 ', s1.IsSubSet(s3));
Writeln('S1 equality S2? ', s1 = s2);
readln;
end.</lang>
{{out}}
<pre>S1 { 1, 2, 3, 4, 5, 6 }
S2 { 2, 3, 4, 5, 6, 8 }
S3 { 1, 2, 5 }
 
4 is in S1? TRUE
S1 union S2 { 1, 2, 3, 4, 5, 6, 8 }
S1 intersection S2 { 2, 3, 4, 5, 6 }
S1 difference S2 { 1 }
S3 is subset S2 TRUE
S1 equality S2? FALSE</pre>
 
=={{header|EchoLisp}}==
478

edits