Talk:Set consolidation: Difference between revisions

→‎Why.: clarify?
(→‎Why.: "Connected components of a graph". Yah!)
(→‎Why.: clarify?)
Line 11:
 
::Hi Ledrug, I wasn't sure of a general need either so left out mentioning order independence from the main task description but just wanted to make sure of my Python code so reported the run of it in the Python docstring. --[[User:Paddy3118|Paddy3118]] 01:13, 8 May 2012 (UTC)
 
::: Also task doesn't make clear what should happen when input contains empty sets. Consider this:<lang python>def conso(s):
if len(s) < 2: return s
 
r, b = [s[0]], conso(s[1:])
for x in b:
if r[0].intersection(x): r[0].update(x)
else: r.append(x)
return r
 
print(conso([{1, 2}, set([]), set([])]))</lang> Is that what you want? --[[User:Ledrug|Ledrug]] 01:44, 8 May 2012 (UTC)
Anonymous user