Talk:Symmetric difference: Difference between revisions

→‎Set type: My overlong, rambling, rebuttal.
(→‎Set type: clarity, data validation and sanitation.)
(→‎Set type: My overlong, rambling, rebuttal.)
Line 24:
 
:::::By changing the task to require input sanitation, it became necessary to mark a number of examples as incorrect, adding templates to identify those examples as requiring attention. If one were to change that requirement to allow noting input constraints as an alternate requirement, the ENAs aren't required, observers of the code are warned of caveats, and the core algorithm is still demonstrated. Does that make sense? --[[User:Short Circuit|Michael Mol]] 05:50, 10 February 2010 (UTC)
 
::::The task asks for an operation of sets. It is reasonable to expect answers to be general over its inputs when those inputs are sets. If we give an answer where the input types are lists and not sets then that is a substitution of one well understood type by another well understood type, who's major differences are that a set is unordered and a list may have duplicates.
::::I think it is reasonable when given a task where you are substituting input types that you either check it works 'as generally'. I think the list solutions would not depend on order, but may fail given duplication. If input types are being substituted then is it obvious that any input lists should/should not have duplicates and should/should not have an order imposed for the algorithm to work?
::::When comparing languages you may be doing a disservice to those that have a set type which automatically works in a more general manner over its inputs.
 
::::Probably gratuitous example that won't help my case :-) <lang python>>>> s0 =list('ABCCD')
>>> # Lists as sets, not handling duplicates
>>> s1 =list('AAEEC')
>>> s0
['A', 'B', 'C', 'C', 'D']
>>> s1
['A', 'A', 'E', 'E', 'C']
>>> ans1 = ( [x for x in s0 if x not in s1] +
[y for y in s1 if y not in s0] )
>>> ans1
['B', 'D', 'E', 'E']
>>>
>>> # Dictionary keys as sets giving the right answer
>>> s0 =dict((k,None) for k in 'ABCCD')
>>> s1 =dict((k,None) for k in 'AAEEC')
>>> s0
{'A': None, 'C': None, 'B': None, 'D': None}
>>> s1
{'A': None, 'C': None, 'E': None}
>>> ans2 = ( [x for x in s0 if x not in s1] +
[y for y in s1 if y not in s0] )
>>> ans2
['B', 'D', 'E']
>>>
>>> # Using sets as inputs
>>> s0 =set('ABCCD')
>>> s1 =set('AAEEC')
>>> ans3 = s0 ^ s1
>>> ans3
{'B', 'E', 'D'}</lang> --[[User:Paddy3118|Paddy3118]] 07:40, 10 February 2010 (UTC)
Anonymous user