Talk:Symmetric difference: Difference between revisions

From Rosetta Code
Content added Content deleted
(Updated, Perl fixed, J marked.)
(Set type problem with list-type solutions.)
Line 7: Line 7:
:I think the task name is good. Symmetric difference is actually an exercise I did in CS classes a few times. I think the task description should be changed to match the task name. --[[User:Mwn3d|Mwn3d]] 02:17, 3 December 2009 (UTC)
:I think the task name is good. Symmetric difference is actually an exercise I did in CS classes a few times. I think the task description should be changed to match the task name. --[[User:Mwn3d|Mwn3d]] 02:17, 3 December 2009 (UTC)
: Description updated, Perl example fixed, J example marked. (I saw that the Python example already provided the symmetric difference. --[[User:Short Circuit|Michael Mol]] 04:23, 3 December 2009 (UTC)
: Description updated, Perl example fixed, J example marked. (I saw that the Python example already provided the symmetric difference. --[[User:Short Circuit|Michael Mol]] 04:23, 3 December 2009 (UTC)

==Set type==
I noticed that the Ruby example was using lists rather than a set datatype. Although its use of lists satisfied the original task decription, in that it gave the correct answer, its use of lists would fall down if, for example, certain duplicates existed in the input lists. No duplicate values would ever exist in any result from a set based solution. Since the task is about sets rather than lists, (and has the Ritzy set expressions to prove it), I modified the task description to force a set-type result, without duplicates. It should hopefully be a small update affected implementations.

If you think an example falls foul of this then maybe you could fix/flag them? Thanks. --[[User:Paddy3118|Paddy3118]] 06:12, 30 January 2010 (UTC)

Revision as of 06:12, 30 January 2010

The symmetric difference should give one list which is the union of the two differences of the lists. The Perl example shows two lists. --Mwn3d 23:19, 2 December 2009 (UTC)

  • I agree with your statement about what “symmetric difference” means.
  • All of the current examples produce two sets.
  • The task as written tends to the two-lists interpretation.

Conclusion: Either the task should be renamed, or the task description should be clarified and the examples revised. --Kevin Reid 02:02, 3 December 2009 (UTC)

I think the task name is good. Symmetric difference is actually an exercise I did in CS classes a few times. I think the task description should be changed to match the task name. --Mwn3d 02:17, 3 December 2009 (UTC)
Description updated, Perl example fixed, J example marked. (I saw that the Python example already provided the symmetric difference. --Michael Mol 04:23, 3 December 2009 (UTC)

Set type

I noticed that the Ruby example was using lists rather than a set datatype. Although its use of lists satisfied the original task decription, in that it gave the correct answer, its use of lists would fall down if, for example, certain duplicates existed in the input lists. No duplicate values would ever exist in any result from a set based solution. Since the task is about sets rather than lists, (and has the Ritzy set expressions to prove it), I modified the task description to force a set-type result, without duplicates. It should hopefully be a small update affected implementations.

If you think an example falls foul of this then maybe you could fix/flag them? Thanks. --Paddy3118 06:12, 30 January 2010 (UTC)