Set consolidation: Difference between revisions

m
{{out}}
(Updated both D entries)
m ({{out}})
Line 12:
:Given the two sets <tt>{A,B}</tt> and <tt>{B,D}</tt> then there is a common element <tt>B</tt> between the sets and the result is the single set <tt>{B,D,A}</tt>. (Note that order of items in a set is immaterial: <tt>{A,B,D}</tt> is the same as <tt>{B,D,A}</tt> and <tt>{D,A,B}</tt>, etc).
;'''Example 3:'''
:Given the three sets <tt>{A,B}</tt> and <tt>{C,D}</tt> and <tt>{D,B}</tt> then there is no common element between the sets <tt>{A,B}</tt> and <tt>{C,D}</tt> but the sets <tt>{A,B}</tt> and <tt>{D,B}</tt> do share a common element that consolidates to produce the result <tt>{B,D,A}</tt>. On examining this result with the remaining set, <tt>{C,D}</tt>, they share a common element and so consolidate to the final output of the single set <tt>{A,B,C,D}</tt>
On examining this result with the remaining set, <tt>{C,D}</tt>, they share a common element and so consolidate to the final output of the single set <tt>{A,B,C,D}</tt>
;'''Example 4:'''
:The consolidation of the five sets:
Line 177 ⟶ 178:
end Set_Consolidation;</lang>
 
{{out}}
This generates the following output:
 
<pre>{A,B}{C,D}
{A,B,D}
Line 350:
& test$(H+I+K A+B C+D D+B F+G+H)
);</lang>
{{out}}
Output:
<pre>A+B C+D ==> A+B C+D
A+B B+D ==> A+B+D
Line 616:
(test (consolidate {{'H' 'I' 'K'} {'A' 'B'} {'C' 'D'} {'D' 'B'} {'F' 'G' 'H'}}))
</lang>
{{out}}
'''Output:'''
<lang egison>
{"DBAC" "HIKFG"}
Line 670:
]
0</lang>
{{out}}
Output
<pre>seq [set ["C"; "D"]; set ["A"; "B"]]
seq [set ["A"; "B"; "C"]]
Line 989:
;;</lang>
 
{{out}}
Output:
 
<pre>{ {A B} {C D} }
{ {A B C} }
Line 1,113 ⟶ 1,112:
End
Return strip(ol)</lang>
{{out}}
Output:
<pre>
Input 1 (B,A) (C,D)
Line 1,364 ⟶ 1,363:
(consolidate (list (set 'h 'i 'k) (set 'a 'b) (set 'c 'd) (set 'd 'b) (set 'f 'g 'h)))
</lang>
{{out}}
Output:
<lang racket>
(list (set 'b 'a) (set 'd 'c))
Line 1,427 ⟶ 1,426:
/*──────────────────────────────────iSIN subroutine─────────────────────*/
isIn: return wordpos(arg(1), arg(2))\==0 /*is (word) arg1 in set arg2? */</lang>
'''output'''{{out}} when using the default supplied sample sets:
<pre>
the old sets= {A,B} {C,D}
Line 1,566 ⟶ 1,565:
(format t "~s -> ~s\n" test (consoli test))))</lang>
 
{{out}}
Output:
 
<pre>((a b) (c d)) -> ((d c) (b a))
((a b) (b d)) -> ((d b a))
Line 1,597 ⟶ 1,595:
[mapcar hash-keys (consoli [mapcar mkset test])])))</lang>
 
{{out}}
Output:
 
<pre>((a b) (c d)) -> ((b a) (d c))
((a b) (b d)) -> ((b a d))
Anonymous user