Power set: Difference between revisions

adding gap
(adding gap)
Line 661:
( 1 2 3 4 )
</pre>
=={{header|GAP}}==
<lang gap># Built-in
Combinations([1,2,3]);
# [ [ ], [ 1 ], [ 1, 2 ], [ 1, 2, 3 ], [ 1, 3 ], [ 2 ], [ 2, 3 ], [ 3 ] ]</lang>
 
# Note that it handles duplicates
Combinations([1,2,3,1]);
# [ [ ], [ 1 ], [ 1, 1 ], [ 1, 1, 2 ], [ 1, 1, 2, 3 ], [ 1, 1, 3 ], [ 1, 2 ], [ 1, 2, 3 ], [ 1, 3 ],
# [ 2 ], [ 2, 3 ], [ 3 ] ]
 
=={{header|Go}}==
No native set type in Go. Instead the associative array trick mentioned in the task description works well in Go. Also this is a good application of the empty interface type, interface{}, to allow different types of objects to be stored in a set.
506

edits