Set consolidation: Difference between revisions

Added Quackery.
(C++ entry)
(Added Quackery.)
Line 2,295:
['ba', 'cd', 'db'] -> [{'d', 'a', 'c', 'b'}]
['ikh', 'ba', 'cd', 'db', 'gfh'] -> [{'d', 'a', 'c', 'b'}, {'i', 'k', 'g', 'h', 'f'}]</pre>
 
=={{header|Quackery}}==
 
<syntaxhighlight lang="Quackery"> [ 0 swap witheach [ bit | ] ] is ->set ( $ --> { )
 
[ say "{" 0 swap
[ dup 0 != while
dup 1 & if
[ over emit ]
1 >> dip 1+ again ]
2drop say "} " ] is echoset ( { --> )
 
[ dup size 2 < if done
[ dup size 1 - times
[ true temp put
behead over
witheach
[ 2dup & iff
[ | swap i^ poke
false temp replace
conclude ]
else drop ]
temp take if join ] ] ] is consolidate ( [ --> [ )
 
[ dup witheach echoset
say "--> "
consolidate witheach echoset
cr ] is task ( [ --> )
 
$ "AB" ->set
$ "CD" ->set join
task
$ "AB" ->set
$ "BD" ->set join
task
$ "AB" ->set
$ "CD" ->set join
$ "DB" ->set join
task
$ "HIK" ->set
$ "AB" ->set join
$ "CD" ->set join
$ "DB" ->set join
$ "FGH" ->set join
task</syntaxhighlight>
 
{{out}}
 
<pre>{AB} {CD} --> {CD} {AB}
{AB} {BD} --> {ABD}
{AB} {CD} {BD} --> {ABCD}
{HIK} {AB} {CD} {BD} {FGH} --> {FGHIK} {ABCD}
</pre>
 
=={{header|Racket}}==
1,467

edits