diff --git a/exercises/list-ops/canonical-data.json b/exercises/list-ops/canonical-data.json index 548d3cb903..da3c0fd430 100644 --- a/exercises/list-ops/canonical-data.json +++ b/exercises/list-ops/canonical-data.json @@ -158,6 +158,12 @@ }, { "description": "folds (reduces) the given list from the left with a function", + "comments": [ + "For function: acc is the accumulator and el is the current element. ", + "The order of the arguments (ie. acc, el or el, acc) should match the ", + "conventions common to the language of the track implementing this. ", + "See https://github.com/exercism/problem-specifications/pull/1746#discussion_r548303995 for further advice." + ], "cases": [ { "uuid": "613b20b7-1873-4070-a3a6-70ae5f50d7cc", @@ -184,6 +190,9 @@ { "uuid": "d2cf5644-aee1-4dfc-9b88-06896676fe27", "description": "direction dependent function applied to non-empty list", + "comments": [ + "Expects integer division (expects / to discard fractions). " + ], "property": "foldl", "input": { "list": [2, 5], @@ -191,11 +200,68 @@ "function": "(x, y) -> x / y" }, "expected": 0 + }, + { + "uuid": "36549237-f765-4a4c-bfd9-5d3a8f7b07d2", + "reimplements": "613b20b7-1873-4070-a3a6-70ae5f50d7cc", + "comments": [ + "Reimplemented to remove ambiguity about the parameters of the ", + "function input." + ], + "description": "empty list", + "property": "foldl", + "input": { + "list": [], + "initial": 2, + "function": "(acc, el) -> el * acc" + }, + "expected": 2 + }, + { + "uuid": "7a626a3c-03ec-42bc-9840-53f280e13067", + "reimplements": "e56df3eb-9405-416a-b13a-aabb4c3b5194", + "comments": [ + "Reimplemented to remove ambiguity about the parameters of the ", + "function input." + ], + "description": "direction independent function applied to non-empty list", + "property": "foldl", + "input": { + "list": [1, 2, 3, 4], + "initial": 5, + "function": "(acc, el) -> el + acc" + }, + "expected": 15 + }, + { + "uuid": "d7fcad99-e88e-40e1-a539-4c519681f390", + "reimplements": "d2cf5644-aee1-4dfc-9b88-06896676fe27", + "comments": [ + "Reimplemented to remove ambiguity about the parameters of the ", + "function input. Expects / to preserve fractions. Integer division", + "will not work here, since it would compute 1 / 24 = 0. Use the ", + "original test values (d2cf5644-aee1-4dfc-9b88-06896676fe27) if ", + "integer division is expected / required. " + ], + "description": "direction dependent function applied to non-empty list", + "property": "foldl", + "input": { + "list": [1, 2, 3, 4], + "initial": 24, + "function": "(acc, el) -> el / acc" + }, + "expected": 64 } ] }, { "description": "folds (reduces) the given list from the right with a function", + "comments": [ + "For function: acc is the accumulator and el is the current element ", + "The order of the arguments (ie. acc, el or el, acc) should match the ", + "conventions common to the language of the track implementing this. ", + "See https://github.com/exercism/problem-specifications/pull/1746#discussion_r548303995 for further advice." + ], "cases": [ { "uuid": "aeb576b9-118e-4a57-a451-db49fac20fdc", @@ -222,6 +288,9 @@ { "uuid": "be396a53-c074-4db3-8dd6-f7ed003cce7c", "description": "direction dependent function applied to non-empty list", + "comments": [ + "Expects integer division (expects / to discard fractions). " + ], "property": "foldr", "input": { "list": [2, 5], @@ -229,6 +298,57 @@ "function": "(x, y) -> x / y" }, "expected": 2 + }, + { + "uuid": "17214edb-20ba-42fc-bda8-000a5ab525b0", + "reimplements": "aeb576b9-118e-4a57-a451-db49fac20fdc", + "comments": [ + "Reimplemented to remove ambiguity about the parameters of the ", + "function input." + ], + "description": "empty list", + "property": "foldr", + "input": { + "list": [], + "initial": 2, + "function": "(acc, el) -> el * acc" + }, + "expected": 2 + }, + { + "uuid": "e1c64db7-9253-4a3d-a7c4-5273b9e2a1bd", + "reimplements": "c4b64e58-313e-4c47-9c68-7764964efb8e", + "comments": [ + "Reimplemented to remove ambiguity about the parameters of the ", + "function input." + ], + "description": "direction independent function applied to non-empty list", + "property": "foldr", + "input": { + "list": [1, 2, 3, 4], + "initial": 5, + "function": "(acc, el) -> el + acc" + }, + "expected": 15 + }, + { + "uuid": "8066003b-f2ff-437e-9103-66e6df474844", + "reimplements": "be396a53-c074-4db3-8dd6-f7ed003cce7c", + "comments": [ + "Reimplemented to remove ambiguity about the parameters of the ", + "function input. Expects / to preserve fractions. Integer division", + "will not work here, since it would compute 4 / 24 = 1 / 6. Use ", + "the original test values (be396a53-c074-4db3-8dd6-f7ed003cce7c) ", + "if integer division is expected / required." + ], + "description": "direction dependent function applied to non-empty list", + "property": "foldr", + "input": { + "list": [1, 2, 3, 4], + "initial": 24, + "function": "(acc, el) -> el / acc" + }, + "expected": 9 } ] },