Skip to content

Commit 34332dc

Browse files
authored
Merge pull request #690 from rbasso/list-ops-schema
list-ops: Make exercise schema-compliant
2 parents b0d4882 + da6b039 commit 34332dc

File tree

1 file changed

+162
-141
lines changed

1 file changed

+162
-141
lines changed
Lines changed: 162 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,168 @@
11
{
2-
"#": [
2+
"exercise": "list-ops",
3+
"version": "1.0.0",
4+
"comments": [
35
"Though there are no specifications here for dealing with large lists,",
46
"implementers may add tests for handling large lists to ensure that the",
57
"solutions have thought about performance concerns."
68
],
7-
"append": {
8-
"description": "append entries to a list and return the new list",
9-
"cases": [
10-
{
11-
"description": "empty lists",
12-
"list1": [],
13-
"list2": [],
14-
"expected": []
15-
},
16-
{
17-
"description": "empty list to list",
18-
"list1": [],
19-
"list2": [1,2,3,4],
20-
"expected": [1,2,3,4]
21-
},
22-
{
23-
"description": "non-empty lists",
24-
"list1": [1,2],
25-
"list2": [2,3,4,5],
26-
"expected": [1,2,2,3,4,5]
27-
}
28-
]
29-
},
30-
"concat": {
31-
"description": "concat lists and lists of list into a new list",
32-
"cases": [
33-
{
34-
"description": "empty list",
35-
"lists": [],
36-
"expected": []
37-
},
38-
{
39-
"description": "list of lists",
40-
"lists": [[1,2],[3],[],[4,5,6]],
41-
"expected": [1,2,3,4,5,6]
42-
}
43-
]
44-
},
45-
"filter": {
46-
"description": "filter list returning only values that satisfy the filter function",
47-
"cases": [
48-
{
49-
"description": "empty list",
50-
"list": [],
51-
"function": "value modulo 2 == 1",
52-
"expected": []
53-
},
54-
{
55-
"description": "non-empty list",
56-
"list": [1,2,3,5],
57-
"function": "value modulo 2 == 1",
58-
"expected": [1,3,5]
59-
}
60-
]
61-
},
62-
"length": {
63-
"description": "returns the length of a list",
64-
"cases": [
65-
{
66-
"description": "empty list",
67-
"list": [],
68-
"expected": 0
69-
},
70-
{
71-
"description": "non-empty list",
72-
"list": [1,2,3,4],
73-
"expected": 4
74-
}
75-
]
76-
},
77-
"map": {
78-
"description": "return a list of elements whos values equal the list value transformed by the mapping function",
79-
"cases": [
80-
{
81-
"description": "empty list",
82-
"list": [],
83-
"function": "value + 1",
84-
"expected": []
85-
},
86-
{
87-
"description": "non-empty list",
88-
"list": [1,3,5,7],
89-
"function": "value + 1",
90-
"expected": [2,4,6,8]
91-
}
92-
]
93-
},
94-
"foldl": {
95-
"description": "folds (reduces) the given list from the left with a function",
96-
"cases": [
97-
{
98-
"description": "empty list",
99-
"list": [],
100-
"initial": 2,
101-
"function": "value / accumulator",
102-
"expected": 2
103-
},
104-
{
105-
"description": "division of integers",
106-
"list": [1,2,3,4],
107-
"initial": 24,
108-
"function": "value / accumulator",
109-
"expected": 64
110-
}
111-
]
112-
},
113-
"foldr": {
114-
"description": "folds (reduces) the given list from the right with a function",
115-
"cases": [
116-
{
117-
"description": "empty list",
118-
"list": [],
119-
"initial": 2,
120-
"function": "value / accumulator",
121-
"expected": 2
122-
},
123-
{
124-
"description": "division of integers",
125-
"list": [1,2,3,4],
126-
"initial": 24,
127-
"function": "value / accumulator",
128-
"expected": 9
129-
}
130-
]
131-
},
132-
"reverse": {
133-
"description": "reverse the elements of the list",
134-
"cases": [
135-
{
136-
"description": "empty list",
137-
"list": [],
138-
"expected": []
139-
},
140-
{
141-
"description": "non-empty list",
142-
"list": [1,3,5,7],
143-
"expected": [7,5,3,1]
144-
}
145-
]
146-
}
9+
"cases": [
10+
{
11+
"description": "append entries to a list and return the new list",
12+
"cases": [
13+
{
14+
"description": "empty lists",
15+
"property": "append",
16+
"list1": [],
17+
"list2": [],
18+
"expected": []
19+
},
20+
{
21+
"description": "empty list to list",
22+
"property": "append",
23+
"list1": [],
24+
"list2": [1, 2, 3, 4],
25+
"expected": [1, 2, 3, 4]
26+
},
27+
{
28+
"description": "non-empty lists",
29+
"property": "append",
30+
"list1": [1, 2],
31+
"list2": [2, 3, 4, 5],
32+
"expected": [1, 2, 2, 3, 4, 5]
33+
}
34+
]
35+
},
36+
{
37+
"description": "concat lists and lists of list into a new list",
38+
"cases": [
39+
{
40+
"description": "empty list",
41+
"property": "concat",
42+
"lists": [],
43+
"expected": []
44+
},
45+
{
46+
"description": "list of lists",
47+
"property": "concat",
48+
"lists": [[1, 2], [3], [], [4, 5, 6]],
49+
"expected": [1, 2, 3, 4, 5, 6]
50+
}
51+
]
52+
},
53+
{
54+
"description": "filter list returning only values that satisfy the filter function",
55+
"cases": [
56+
{
57+
"description": "empty list",
58+
"property": "filter",
59+
"list": [],
60+
"function": "value modulo 2 == 1",
61+
"expected": []
62+
},
63+
{
64+
"description": "non-empty list",
65+
"property": "filter",
66+
"list": [1, 2, 3, 5],
67+
"function": "value modulo 2 == 1",
68+
"expected": [1, 3, 5]
69+
}
70+
]
71+
},
72+
{
73+
"description": "returns the length of a list",
74+
"cases": [
75+
{
76+
"description": "empty list",
77+
"property": "length",
78+
"list": [],
79+
"expected": 0
80+
},
81+
{
82+
"description": "non-empty list",
83+
"property": "length",
84+
"list": [1, 2, 3, 4],
85+
"expected": 4
86+
}
87+
]
88+
},
89+
{
90+
"description": "return a list of elements whos values equal the list value transformed by the mapping function",
91+
"cases": [
92+
{
93+
"description": "empty list",
94+
"property": "map",
95+
"list": [],
96+
"function": "value + 1",
97+
"expected": []
98+
},
99+
{
100+
"description": "non-empty list",
101+
"property": "map",
102+
"list": [1, 3, 5, 7],
103+
"function": "value + 1",
104+
"expected": [2, 4, 6, 8]
105+
}
106+
]
107+
},
108+
{
109+
"description": "folds (reduces) the given list from the left with a function",
110+
"cases": [
111+
{
112+
"description": "empty list",
113+
"property": "foldl",
114+
"list": [],
115+
"initial": 2,
116+
"function": "value / accumulator",
117+
"expected": 2
118+
},
119+
{
120+
"description": "division of integers",
121+
"property": "foldl",
122+
"list": [1, 2, 3, 4],
123+
"initial": 24,
124+
"function": "value / accumulator",
125+
"expected": 64
126+
}
127+
]
128+
},
129+
{
130+
"description": "folds (reduces) the given list from the right with a function",
131+
"cases": [
132+
{
133+
"description": "empty list",
134+
"property": "foldr",
135+
"list": [],
136+
"initial": 2,
137+
"function": "value / accumulator",
138+
"expected": 2
139+
},
140+
{
141+
"description": "division of integers",
142+
"property": "foldr",
143+
"list": [1, 2, 3, 4],
144+
"initial": 24,
145+
"function": "value / accumulator",
146+
"expected": 9
147+
}
148+
]
149+
},
150+
{
151+
"description": "reverse the elements of the list",
152+
"cases": [
153+
{
154+
"description": "empty list",
155+
"property": "reverse",
156+
"list": [],
157+
"expected": []
158+
},
159+
{
160+
"description": "non-empty list",
161+
"property": "reverse",
162+
"list": [1, 3, 5, 7],
163+
"expected": [7, 5, 3, 1]
164+
}
165+
]
166+
}
167+
]
147168
}

0 commit comments

Comments
 (0)