Problem-specifications: Clarify purpose of list-ops concat function

Created on 27 Apr 2018  路  2Comments  路  Source: exercism/problem-specifications

I think it's supposed to take a list of lists, and concatenate all the lists together.
But I've seen some implementations that think it's supposed to flatten the lists.
Both implementations pass, though they are radically different.

Ref: https://github.com/exercism/problem-specifications/pull/521

Most helpful comment

My personal interpretation was that concat's type should be [[a]] -> [a]. This is equivalent to me having said "I expect it to flatten exactly one level, no more and no less". I do not expect arbitrary flattening, because that implies the input list will have elements of heterogeneous type.

https://github.com/exercism/problem-specifications/pull/521#discussion_r98729726 is documentation of my having held this interpretation.

All 2 comments

My personal interpretation was that concat's type should be [[a]] -> [a]. This is equivalent to me having said "I expect it to flatten exactly one level, no more and no less". I do not expect arbitrary flattening, because that implies the input list will have elements of heterogeneous type.

https://github.com/exercism/problem-specifications/pull/521#discussion_r98729726 is documentation of my having held this interpretation.

My personal interpretation was that concat's type should be [[a]] -> [a].

I concur. Maybe it would be prudent to add a test similar to the following?

{
          "description": "list of nested lists",
          "property": "concat",
          "input": {
            "lists": [[[1, 2]], [[3]], [[]], [[4, 5, 6]]]
          },
          "expected": [[1, 2], [3], [], [4, 5, 6]]
}
Was this page helpful?
0 / 5 - 0 ratings