trackler 2.2.1.155 → 2.2.1.156
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +3 -0
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/simple-cipher/canonical-data.json +147 -0
- data/tracks/clojure/exercises/hexadecimal/src/hexadecimal.clj +5 -0
- data/tracks/clojure/exercises/isogram/src/isogram.clj +5 -0
- data/tracks/clojure/exercises/kindergarten-garden/src/kindergarten-garden.clj +5 -0
- data/tracks/csharp/exercises/list-ops/Example.cs +14 -9
- data/tracks/csharp/exercises/list-ops/ListOps.cs +4 -4
- data/tracks/csharp/exercises/list-ops/ListOpsTest.cs +90 -88
- data/tracks/csharp/exercises/zipper/Example.cs +51 -43
- data/tracks/csharp/exercises/zipper/Zipper.cs +16 -19
- data/tracks/csharp/exercises/zipper/ZipperTest.cs +94 -45
- data/tracks/csharp/generators/Exercises/ListOps.cs +123 -0
- data/tracks/csharp/generators/Exercises/Zipper.cs +107 -0
- data/tracks/csharp/generators/Output/ValueFormatter.cs +14 -0
- data/tracks/delphi/config.json +10 -1
- data/tracks/delphi/config/maintainers.json +11 -11
- data/tracks/elisp/config.json +8 -0
- data/tracks/elisp/exercises/run-length-encoding/README.md +36 -0
- data/tracks/elisp/exercises/run-length-encoding/example.el +62 -0
- data/tracks/elisp/exercises/run-length-encoding/run-length-encoding-test.el +61 -0
- data/tracks/elisp/exercises/run-length-encoding/run-length-encoding.el +9 -0
- data/tracks/fsharp/docs/LEARNING.md +3 -0
- data/tracks/java/exercises/armstrong-numbers/.meta/hints.md +2 -0
- data/tracks/java/exercises/armstrong-numbers/README.md +6 -0
- data/tracks/java/exercises/bracket-push/.meta/version +1 -1
- data/tracks/java/exercises/bracket-push/src/test/java/BracketCheckerTest.java +7 -0
- data/tracks/java/exercises/isbn-verifier/.meta/version +1 -1
- data/tracks/java/exercises/isbn-verifier/src/test/java/IsbnVerifierTest.java +12 -1
- data/tracks/java/exercises/kindergarten-garden/.meta/version +1 -1
- data/tracks/java/exercises/list-ops/.meta/version +1 -1
- data/tracks/java/exercises/list-ops/src/test/java/ListOpsTest.java +32 -1
- data/tracks/nim/config.json +13 -2
- data/tracks/nim/exercises/bob/bob_test.nim +1 -1
- data/tracks/nim/exercises/bob/example.nim +6 -3
- data/tracks/nim/exercises/bracket-push/README.md +11 -0
- data/tracks/nim/exercises/bracket-push/bracket_push_test.nim +52 -0
- data/tracks/nim/exercises/bracket-push/example.nim +22 -0
- data/tracks/ocaml/exercises/bracket-push/test.ml +3 -1
- data/tracks/ocaml/exercises/luhn/example.ml +8 -5
- data/tracks/ocaml/exercises/luhn/test.ml +3 -1
- data/tracks/powershell/.gitignore +2 -1
- data/tracks/powershell/config.json +46 -13
- data/tracks/powershell/exercises/bob/.version +1 -0
- data/tracks/powershell/exercises/bob/BobResponse.example.ps1 +28 -0
- data/tracks/powershell/exercises/bob/BobResponse.ps1 +8 -0
- data/tracks/powershell/exercises/bob/BobResponse.tests.ps1 +109 -0
- data/tracks/powershell/exercises/bob/README.md +20 -0
- data/tracks/powershell/exercises/nucleotide-count/.version +1 -0
- data/tracks/powershell/exercises/nucleotide-count/NucleotideCount.example.ps1 +36 -0
- data/tracks/powershell/exercises/nucleotide-count/NucleotideCount.ps1 +8 -0
- data/tracks/powershell/exercises/nucleotide-count/NucleotideCount.tests.ps1 +25 -0
- data/tracks/powershell/exercises/nucleotide-count/README.md +19 -0
- data/tracks/powershell/exercises/raindrops/.version +1 -0
- data/tracks/powershell/exercises/raindrops/README.md +24 -0
- data/tracks/powershell/exercises/raindrops/Raindrops.example.ps1 +32 -0
- data/tracks/powershell/exercises/raindrops/Raindrops.ps1 +8 -0
- data/tracks/powershell/exercises/raindrops/Raindrops.tests.ps1 +34 -0
- data/tracks/prolog/exercises/complex-numbers/complex_numbers_tests.plt +28 -29
- data/tracks/reasonml/.gitignore +4 -0
- data/tracks/reasonml/.travis.yml +5 -0
- data/tracks/reasonml/LICENSE +21 -0
- data/tracks/reasonml/README.md +67 -0
- data/tracks/reasonml/bin/fetch-configlet +32 -0
- data/tracks/reasonml/config.json +11 -0
- data/tracks/reasonml/config/exercise-readme-insert.md +0 -0
- data/tracks/reasonml/config/exercise_readme.go.tmpl +16 -0
- data/tracks/reasonml/config/maintainers.json +4 -0
- data/tracks/reasonml/docs/ABOUT.md +0 -0
- data/tracks/reasonml/docs/INSTALLATION.md +0 -0
- data/tracks/reasonml/docs/LEARNING.md +0 -0
- data/tracks/reasonml/docs/RESOURCES.md +0 -0
- data/tracks/reasonml/docs/TESTS.md +0 -0
- data/tracks/reasonml/img/.keep +0 -0
- data/tracks/scala/config.json +11 -0
- data/tracks/scala/exercises/armstrong-numbers/README.md +29 -0
- data/tracks/scala/exercises/armstrong-numbers/build.sbt +3 -0
- data/tracks/scala/exercises/armstrong-numbers/example.scala +7 -0
- data/tracks/scala/exercises/armstrong-numbers/src/main/scala/.keep +0 -0
- data/tracks/scala/exercises/armstrong-numbers/src/test/scala/ArmstrongNumbersTest.scala +44 -0
- data/tracks/scala/testgen/src/main/scala/ArmstrongNumbersTestGenerator.scala +33 -0
- data/tracks/scheme/config.json +8 -0
- data/tracks/scheme/exercises/atbash-cipher/README.md +36 -0
- data/tracks/scheme/exercises/atbash-cipher/atbash-cipher-test.scm +67 -0
- data/tracks/scheme/exercises/atbash-cipher/atbash-cipher.scm +8 -0
- data/tracks/scheme/exercises/atbash-cipher/example.scm +40 -0
- metadata +57 -3
- data/tracks/python/exercises/rna-transcription/.meta/hints.md +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9be9297151cb81a1a1f348f7fecda5fb043f0cba
|
4
|
+
data.tar.gz: b71394646b1a1ff43954c04fa98f94843b04f7bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62f2aa2dee62bac25a506f182562ef2615953f20ac0c333d666909d773a10da3ab2c00a2dd6458e872d2d457fb699eb612ba95ee25ae2fe59c879e0f8862d5ed
|
7
|
+
data.tar.gz: 322eeb246ff474e163fedcdcb1d9903ac974a62a7cacbb6d97b440af044d3c845167aa4fefbd240fc3b90c57f5676fe4a2419524d6b210843487b3bbf05d52c7
|
data/.gitmodules
CHANGED
data/lib/trackler/version.rb
CHANGED
@@ -0,0 +1,147 @@
|
|
1
|
+
{
|
2
|
+
"exercise": "simple-cipher",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"comments":
|
5
|
+
["Some of the strings used in this file are symbolic and do not represent their literal value. They are:",
|
6
|
+
"cipher.key - Represents the Cipher key",
|
7
|
+
"cipher.encode - Represents the output of the Cipher encode method",
|
8
|
+
"new - Represents the Cipher initialization"],
|
9
|
+
"cases": [
|
10
|
+
{
|
11
|
+
"description": "Random key cipher",
|
12
|
+
"cases": [
|
13
|
+
{
|
14
|
+
"description": "Can encode",
|
15
|
+
"property": "encode",
|
16
|
+
"input": {
|
17
|
+
"plaintext": "aaaaaaaaaa"
|
18
|
+
},
|
19
|
+
"expected": "cipher.key"
|
20
|
+
},
|
21
|
+
{
|
22
|
+
"description": "Can decode",
|
23
|
+
"property": "decode",
|
24
|
+
"input": {
|
25
|
+
"ciphertext": "cipher.key"
|
26
|
+
},
|
27
|
+
"expected": "aaaaaaaaaa"
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"description": "Is reversible. I.e., if you apply decode in a encoded result, you must see the same plaintext encode parameter as a result of the decode method",
|
31
|
+
"property": "decode",
|
32
|
+
"input": {
|
33
|
+
"plaintext": "abcdefghij",
|
34
|
+
"ciphertext": "cipher.encode"
|
35
|
+
},
|
36
|
+
"expected": "abcdefghij"
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"description": "Key is made only of lowercase letters",
|
40
|
+
"property": "key",
|
41
|
+
"input": {},
|
42
|
+
"expected": {
|
43
|
+
"match": "^[a-z]+$"
|
44
|
+
}
|
45
|
+
}
|
46
|
+
]
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"description": "Substitution cipher",
|
50
|
+
"cases": [
|
51
|
+
{
|
52
|
+
"description": "Can encode",
|
53
|
+
"property": "encode",
|
54
|
+
"input": {
|
55
|
+
"key": "abcdefghij",
|
56
|
+
"plaintext": "aaaaaaaaaa"
|
57
|
+
},
|
58
|
+
"expected": "abcdefghij"
|
59
|
+
},
|
60
|
+
{
|
61
|
+
"description": "Can decode",
|
62
|
+
"property": "decode",
|
63
|
+
"input": {
|
64
|
+
"key": "abcdefghij",
|
65
|
+
"ciphertext": "abcdefghij"
|
66
|
+
},
|
67
|
+
"expected": "aaaaaaaaaa"
|
68
|
+
},
|
69
|
+
{
|
70
|
+
"description": "Is reversible. I.e., if you apply decode in a encoded result, you must see the same plaintext encode parameter as a result of the decode method",
|
71
|
+
"property": "decode",
|
72
|
+
"input": {
|
73
|
+
"key": "abcdefghij",
|
74
|
+
"plaintext": "abcdefghij",
|
75
|
+
"ciphertext": "cipher.encode"
|
76
|
+
},
|
77
|
+
"expected": "abcdefghij"
|
78
|
+
},
|
79
|
+
{
|
80
|
+
"description": "Can double shift encode",
|
81
|
+
"property": "encode",
|
82
|
+
"input": {
|
83
|
+
"key": "iamapandabear",
|
84
|
+
"plaintext": "iamapandabear"
|
85
|
+
},
|
86
|
+
"expected": "qayaeaagaciai"
|
87
|
+
},
|
88
|
+
{
|
89
|
+
"description": "Can wrap on encode",
|
90
|
+
"property": "encode",
|
91
|
+
"input": {
|
92
|
+
"key": "abcdefghij",
|
93
|
+
"plaintext": "zzzzzzzzzz"
|
94
|
+
},
|
95
|
+
"expected": "zabcdefghi"
|
96
|
+
},
|
97
|
+
{
|
98
|
+
"description": "Can wrap on decode",
|
99
|
+
"property": "decode",
|
100
|
+
"input": {
|
101
|
+
"key": "abcdefghij",
|
102
|
+
"ciphertext": "zabcdefghi"
|
103
|
+
},
|
104
|
+
"expected": "zzzzzzzzzz"
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"description": "Can handle messages longer than the key",
|
108
|
+
"property": "encode",
|
109
|
+
"input": {
|
110
|
+
"key": "abc",
|
111
|
+
"plaintext": "iamapandabear"
|
112
|
+
},
|
113
|
+
"expected": "iboaqcnecbfcr"
|
114
|
+
}
|
115
|
+
]
|
116
|
+
},
|
117
|
+
{
|
118
|
+
"description": "Incorrect key cipher",
|
119
|
+
"cases": [
|
120
|
+
{
|
121
|
+
"description": "Throws an error with an all uppercase key",
|
122
|
+
"property": "new",
|
123
|
+
"input": {
|
124
|
+
"key": "ABCDEF"
|
125
|
+
},
|
126
|
+
"expected": { "error": "Bad key" }
|
127
|
+
},
|
128
|
+
{
|
129
|
+
"description": "Throws an error with a numeric key",
|
130
|
+
"property": "new",
|
131
|
+
"input": {
|
132
|
+
"key": "12345"
|
133
|
+
},
|
134
|
+
"expected": { "error": "Bad key" }
|
135
|
+
},
|
136
|
+
{
|
137
|
+
"description": "Throws an error with empty key",
|
138
|
+
"property": "new",
|
139
|
+
"input": {
|
140
|
+
"key": ""
|
141
|
+
},
|
142
|
+
"expected": { "error": "Bad key" }
|
143
|
+
}
|
144
|
+
]
|
145
|
+
}
|
146
|
+
]
|
147
|
+
}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
using System;
|
2
|
+
using System.Collections;
|
2
3
|
using System.Collections.Generic;
|
3
4
|
using System.Linq;
|
4
5
|
|
@@ -14,25 +15,25 @@ private static List<T> Cons<T>(T x, List<T> input)
|
|
14
15
|
|
15
16
|
public static int Length<T>(List<T> input)
|
16
17
|
{
|
17
|
-
return Foldl((acc, x) => acc + 1
|
18
|
+
return Foldl(input, 0, (acc, x) => acc + 1);
|
18
19
|
}
|
19
20
|
|
20
21
|
public static List<T> Reverse<T>(List<T> input)
|
21
22
|
{
|
22
|
-
return Foldl((acc, x) => Cons(x, acc)
|
23
|
+
return Foldl(input, new List<T>(), (acc, x) => Cons(x, acc));
|
23
24
|
}
|
24
25
|
|
25
|
-
public static List<TOut> Map<TIn, TOut>(
|
26
|
+
public static List<TOut> Map<TIn, TOut>(List<TIn> input, Func<TIn, TOut> map)
|
26
27
|
{
|
27
|
-
return Foldr((x, acc) => Cons(map(x), acc)
|
28
|
+
return Foldr(input, new List<TOut>(), (x, acc) => Cons(map(x), acc));
|
28
29
|
}
|
29
30
|
|
30
|
-
public static List<T> Filter<T>(
|
31
|
+
public static List<T> Filter<T>(List<T> input, Func<T, bool> predicate)
|
31
32
|
{
|
32
|
-
return Foldr((x, acc) => predicate(x) ? Cons(x, acc) : acc
|
33
|
+
return Foldr(input, new List<T>(), (x, acc) => predicate(x) ? Cons(x, acc) : acc);
|
33
34
|
}
|
34
35
|
|
35
|
-
public static TOut Foldl<TIn, TOut>(
|
36
|
+
public static TOut Foldl<TIn, TOut>(List<TIn> input, TOut start, Func<TOut, TIn, TOut> func)
|
36
37
|
{
|
37
38
|
var acc = start;
|
38
39
|
|
@@ -42,7 +43,7 @@ public static List<T> Filter<T>(Func<T, bool> predicate, List<T> input)
|
|
42
43
|
return acc;
|
43
44
|
}
|
44
45
|
|
45
|
-
public static TOut Foldr<TIn, TOut>(
|
46
|
+
public static TOut Foldr<TIn, TOut>(List<TIn> input, TOut start, Func<TIn, TOut, TOut> func)
|
46
47
|
{
|
47
48
|
var acc = start;
|
48
49
|
|
@@ -57,7 +58,11 @@ public static List<T> Concat<T>(List<List<T>> input)
|
|
57
58
|
var concatenated = new List<T>();
|
58
59
|
|
59
60
|
foreach (var list in input)
|
60
|
-
|
61
|
+
{
|
62
|
+
if (list is List<T> sublist)
|
63
|
+
concatenated = Append(concatenated, sublist);
|
64
|
+
}
|
65
|
+
|
61
66
|
|
62
67
|
return concatenated;
|
63
68
|
}
|
@@ -14,22 +14,22 @@ public static List<T> Reverse<T>(List<T> input)
|
|
14
14
|
throw new NotImplementedException("You need to implement this function.");
|
15
15
|
}
|
16
16
|
|
17
|
-
public static List<TOut> Map<TIn, TOut>(
|
17
|
+
public static List<TOut> Map<TIn, TOut>(List<TIn> input, Func<TIn, TOut> map)
|
18
18
|
{
|
19
19
|
throw new NotImplementedException("You need to implement this function.");
|
20
20
|
}
|
21
21
|
|
22
|
-
public static List<T> Filter<T>(
|
22
|
+
public static List<T> Filter<T>(List<T> input, Func<T, bool> predicate)
|
23
23
|
{
|
24
24
|
throw new NotImplementedException("You need to implement this function.");
|
25
25
|
}
|
26
26
|
|
27
|
-
public static TOut Foldl<TIn, TOut>(
|
27
|
+
public static TOut Foldl<TIn, TOut>(List<TIn> input, TOut start, Func<TOut, TIn, TOut> func)
|
28
28
|
{
|
29
29
|
throw new NotImplementedException("You need to implement this function.");
|
30
30
|
}
|
31
31
|
|
32
|
-
public static TOut Foldr<TIn, TOut>(
|
32
|
+
public static TOut Foldr<TIn, TOut>(List<TIn> input, TOut start, Func<TIn, TOut, TOut> func)
|
33
33
|
{
|
34
34
|
throw new NotImplementedException("You need to implement this function.");
|
35
35
|
}
|
@@ -1,172 +1,174 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
// This file was auto-generated based on version 2.3.0 of the canonical data.
|
2
|
+
|
3
3
|
using Xunit;
|
4
|
+
using System;
|
5
|
+
using System.Collections.Generic;
|
4
6
|
|
5
7
|
public class ListOpsTest
|
6
8
|
{
|
7
|
-
private const int Big = 10000;
|
8
|
-
private static readonly List<int> BigList = Range(1, Big);
|
9
|
-
private static readonly List<int> EmptyList = new List<int>();
|
10
|
-
|
11
|
-
private static List<int> Range(int from, int until) => new List<int>(Enumerable.Range(from, (until - from) + 1));
|
12
|
-
private static bool Odd(int x) => x % 2 == 1;
|
13
|
-
|
14
|
-
private static List<T> Cons<T>(T x, List<T> input)
|
15
|
-
{
|
16
|
-
var list = new List<T>(input);
|
17
|
-
list.Insert(0, x);
|
18
|
-
|
19
|
-
return list;
|
20
|
-
}
|
21
|
-
|
22
9
|
[Fact]
|
23
|
-
public void
|
24
|
-
{
|
25
|
-
Assert.Equal(0, ListOps.Length(EmptyList));
|
26
|
-
}
|
27
|
-
|
28
|
-
[Fact(Skip = "Remove to run test")]
|
29
|
-
public void LengthOfNonEmptyList()
|
30
|
-
{
|
31
|
-
Assert.Equal(4, ListOps.Length(Range(1, 4)));
|
32
|
-
}
|
33
|
-
|
34
|
-
[Fact(Skip = "Remove to run test")]
|
35
|
-
public void LengthOfLargeList()
|
36
|
-
{
|
37
|
-
Assert.Equal(Big, ListOps.Length(Range(1, Big)));
|
38
|
-
}
|
39
|
-
|
40
|
-
[Fact(Skip = "Remove to run test")]
|
41
|
-
public void ReverseOfEmptylist()
|
42
|
-
{
|
43
|
-
Assert.Equal(EmptyList, ListOps.Reverse(EmptyList));
|
44
|
-
}
|
45
|
-
|
46
|
-
[Fact(Skip = "Remove to run test")]
|
47
|
-
public void ReverseOfNonEmptyList()
|
10
|
+
public void Append_entries_to_a_list_and_return_the_new_list_empty_lists()
|
48
11
|
{
|
49
|
-
|
12
|
+
var list1 = new List<int>();
|
13
|
+
var list2 = new List<int>();
|
14
|
+
Assert.Empty(ListOps.Append(list1, list2));
|
50
15
|
}
|
51
16
|
|
52
17
|
[Fact(Skip = "Remove to run test")]
|
53
|
-
public void
|
18
|
+
public void Append_entries_to_a_list_and_return_the_new_list_empty_list_to_list()
|
54
19
|
{
|
55
|
-
|
20
|
+
var list1 = new List<int>();
|
21
|
+
var list2 = new List<int> { 1, 2, 3, 4 };
|
22
|
+
var expected = new List<int> { 1, 2, 3, 4 };
|
23
|
+
Assert.Equal(expected, ListOps.Append(list1, list2));
|
56
24
|
}
|
57
25
|
|
58
26
|
[Fact(Skip = "Remove to run test")]
|
59
|
-
public void
|
27
|
+
public void Append_entries_to_a_list_and_return_the_new_list_non_empty_lists()
|
60
28
|
{
|
61
|
-
|
29
|
+
var list1 = new List<int> { 1, 2 };
|
30
|
+
var list2 = new List<int> { 2, 3, 4, 5 };
|
31
|
+
var expected = new List<int> { 1, 2, 2, 3, 4, 5 };
|
32
|
+
Assert.Equal(expected, ListOps.Append(list1, list2));
|
62
33
|
}
|
63
34
|
|
64
35
|
[Fact(Skip = "Remove to run test")]
|
65
|
-
public void
|
36
|
+
public void Concatenate_a_list_of_lists_empty_list()
|
66
37
|
{
|
67
|
-
|
38
|
+
var lists = new List<List<int>>();
|
39
|
+
Assert.Empty(ListOps.Concat(lists));
|
68
40
|
}
|
69
41
|
|
70
42
|
[Fact(Skip = "Remove to run test")]
|
71
|
-
public void
|
43
|
+
public void Concatenate_a_list_of_lists_list_of_lists()
|
72
44
|
{
|
73
|
-
|
45
|
+
var lists = new List<List<int>> { new List<int> { 1, 2 }, new List<int> { 3 }, new List<int>(), new List<int> { 4, 5, 6 } };
|
46
|
+
var expected = new List<int> { 1, 2, 3, 4, 5, 6 };
|
47
|
+
Assert.Equal(expected, ListOps.Concat(lists));
|
74
48
|
}
|
75
49
|
|
76
50
|
[Fact(Skip = "Remove to run test")]
|
77
|
-
public void
|
51
|
+
public void Concatenate_a_list_of_lists_list_of_nested_lists()
|
78
52
|
{
|
79
|
-
|
53
|
+
var lists = new List<List<List<int>>> { new List<List<int>> { new List<int> { 1 }, new List<int> { 2 } }, new List<List<int>> { new List<int> { 3 } }, new List<List<int>> { new List<int>() }, new List<List<int>> { new List<int> { 4, 5, 6 } } };
|
54
|
+
var expected = new List<List<int>> { new List<int> { 1 }, new List<int> { 2 }, new List<int> { 3 }, new List<int>(), new List<int> { 4, 5, 6 } };
|
55
|
+
Assert.Equal(expected, ListOps.Concat(lists));
|
80
56
|
}
|
81
57
|
|
82
58
|
[Fact(Skip = "Remove to run test")]
|
83
|
-
public void
|
59
|
+
public void Filter_list_returning_only_values_that_satisfy_the_filter_function_empty_list()
|
84
60
|
{
|
85
|
-
|
61
|
+
var list = new List<int>();
|
62
|
+
var function = new Func<int, bool>((x) => x % 2 == 1);
|
63
|
+
Assert.Empty(ListOps.Filter(list, function));
|
86
64
|
}
|
87
65
|
|
88
66
|
[Fact(Skip = "Remove to run test")]
|
89
|
-
public void
|
67
|
+
public void Filter_list_returning_only_values_that_satisfy_the_filter_function_non_empty_list()
|
90
68
|
{
|
91
|
-
|
69
|
+
var list = new List<int> { 1, 2, 3, 5 };
|
70
|
+
var function = new Func<int, bool>((x) => x % 2 == 1);
|
71
|
+
var expected = new List<int> { 1, 3, 5 };
|
72
|
+
Assert.Equal(expected, ListOps.Filter(list, function));
|
92
73
|
}
|
93
74
|
|
94
75
|
[Fact(Skip = "Remove to run test")]
|
95
|
-
public void
|
76
|
+
public void Returns_the_length_of_a_list_empty_list()
|
96
77
|
{
|
97
|
-
|
78
|
+
var list = new List<int>();
|
79
|
+
Assert.Equal(0, ListOps.Length(list));
|
98
80
|
}
|
99
81
|
|
100
82
|
[Fact(Skip = "Remove to run test")]
|
101
|
-
public void
|
83
|
+
public void Returns_the_length_of_a_list_non_empty_list()
|
102
84
|
{
|
103
|
-
|
85
|
+
var list = new List<int> { 1, 2, 3, 4 };
|
86
|
+
Assert.Equal(4, ListOps.Length(list));
|
104
87
|
}
|
105
88
|
|
106
89
|
[Fact(Skip = "Remove to run test")]
|
107
|
-
public void
|
90
|
+
public void Return_a_list_of_elements_whose_values_equal_the_list_value_transformed_by_the_mapping_function_empty_list()
|
108
91
|
{
|
109
|
-
|
92
|
+
var list = new List<int>();
|
93
|
+
var function = new Func<int, int>((x) => x + 1);
|
94
|
+
Assert.Empty(ListOps.Map(list, function));
|
110
95
|
}
|
111
96
|
|
112
97
|
[Fact(Skip = "Remove to run test")]
|
113
|
-
public void
|
98
|
+
public void Return_a_list_of_elements_whose_values_equal_the_list_value_transformed_by_the_mapping_function_non_empty_list()
|
114
99
|
{
|
115
|
-
|
100
|
+
var list = new List<int> { 1, 3, 5, 7 };
|
101
|
+
var function = new Func<int, int>((x) => x + 1);
|
102
|
+
var expected = new List<int> { 2, 4, 6, 8 };
|
103
|
+
Assert.Equal(expected, ListOps.Map(list, function));
|
116
104
|
}
|
117
105
|
|
118
106
|
[Fact(Skip = "Remove to run test")]
|
119
|
-
public void
|
107
|
+
public void Folds_reduces_the_given_list_from_the_left_with_a_function_empty_list()
|
120
108
|
{
|
121
|
-
|
109
|
+
var list = new List<int>();
|
110
|
+
var initial = 2;
|
111
|
+
var function = new Func<int, int, int>((x, y) => x * y);
|
112
|
+
Assert.Equal(2, ListOps.Foldl(list, initial, function));
|
122
113
|
}
|
123
114
|
|
124
115
|
[Fact(Skip = "Remove to run test")]
|
125
|
-
public void
|
116
|
+
public void Folds_reduces_the_given_list_from_the_left_with_a_function_direction_independent_function_applied_to_non_empty_list()
|
126
117
|
{
|
127
|
-
|
118
|
+
var list = new List<int> { 1, 2, 3, 4 };
|
119
|
+
var initial = 5;
|
120
|
+
var function = new Func<int, int, int>((x, y) => x + y);
|
121
|
+
Assert.Equal(15, ListOps.Foldl(list, initial, function));
|
128
122
|
}
|
129
123
|
|
130
124
|
[Fact(Skip = "Remove to run test")]
|
131
|
-
public void
|
125
|
+
public void Folds_reduces_the_given_list_from_the_left_with_a_function_direction_dependent_function_applied_to_non_empty_list()
|
132
126
|
{
|
133
|
-
|
127
|
+
var list = new List<int> { 2, 5 };
|
128
|
+
var initial = 5;
|
129
|
+
var function = new Func<int, int, int>((x, y) => x / y);
|
130
|
+
Assert.Equal(0, ListOps.Foldl(list, initial, function));
|
134
131
|
}
|
135
132
|
|
136
133
|
[Fact(Skip = "Remove to run test")]
|
137
|
-
public void
|
134
|
+
public void Folds_reduces_the_given_list_from_the_right_with_a_function_empty_list()
|
138
135
|
{
|
139
|
-
|
136
|
+
var list = new List<int>();
|
137
|
+
var initial = 2;
|
138
|
+
var function = new Func<int, int, int>((x, y) => x * y);
|
139
|
+
Assert.Equal(2, ListOps.Foldr(list, initial, function));
|
140
140
|
}
|
141
141
|
|
142
142
|
[Fact(Skip = "Remove to run test")]
|
143
|
-
public void
|
143
|
+
public void Folds_reduces_the_given_list_from_the_right_with_a_function_direction_independent_function_applied_to_non_empty_list()
|
144
144
|
{
|
145
|
-
|
145
|
+
var list = new List<int> { 1, 2, 3, 4 };
|
146
|
+
var initial = 5;
|
147
|
+
var function = new Func<int, int, int>((x, y) => x + y);
|
148
|
+
Assert.Equal(15, ListOps.Foldr(list, initial, function));
|
146
149
|
}
|
147
150
|
|
148
151
|
[Fact(Skip = "Remove to run test")]
|
149
|
-
public void
|
152
|
+
public void Folds_reduces_the_given_list_from_the_right_with_a_function_direction_dependent_function_applied_to_non_empty_list()
|
150
153
|
{
|
151
|
-
|
154
|
+
var list = new List<int> { 2, 5 };
|
155
|
+
var initial = 5;
|
156
|
+
var function = new Func<int, int, int>((x, y) => x / y);
|
157
|
+
Assert.Equal(2, ListOps.Foldr(list, initial, function));
|
152
158
|
}
|
153
159
|
|
154
160
|
[Fact(Skip = "Remove to run test")]
|
155
|
-
public void
|
161
|
+
public void Reverse_the_elements_of_the_list_empty_list()
|
156
162
|
{
|
157
|
-
|
158
|
-
|
159
|
-
{
|
160
|
-
new List<int> {1, 2},
|
161
|
-
new List<int> {3},
|
162
|
-
EmptyList,
|
163
|
-
new List<int> {4, 5, 6}
|
164
|
-
}));
|
163
|
+
var list = new List<int>();
|
164
|
+
Assert.Empty(ListOps.Reverse(list));
|
165
165
|
}
|
166
166
|
|
167
167
|
[Fact(Skip = "Remove to run test")]
|
168
|
-
public void
|
168
|
+
public void Reverse_the_elements_of_the_list_non_empty_list()
|
169
169
|
{
|
170
|
-
|
170
|
+
var list = new List<int> { 1, 3, 5, 7 };
|
171
|
+
var expected = new List<int> { 7, 5, 3, 1 };
|
172
|
+
Assert.Equal(expected, ListOps.Reverse(list));
|
171
173
|
}
|
172
174
|
}
|