trackler 2.2.1.24 → 2.2.1.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/TOPICS.txt +73 -73
- data/tracks/bash/config.json +82 -73
- data/tracks/bash/config/maintainers.json +9 -9
- data/tracks/bash/exercises/nucleotide-count/README.md +38 -0
- data/tracks/bash/exercises/nucleotide-count/example.sh +38 -0
- data/tracks/bash/exercises/nucleotide-count/nucleotide_count_test.sh +29 -0
- data/tracks/csharp/.travis.yml +9 -2
- data/tracks/csharp/build.cake +7 -34
- data/tracks/csharp/build.ps1 +2 -2
- data/tracks/csharp/build.sh +2 -2
- data/tracks/csharp/docs/GENERATORS.md +102 -0
- data/tracks/csharp/exercises/Exercises.sln +669 -0
- data/tracks/csharp/exercises/queen-attack/Example.cs +14 -1
- data/tracks/csharp/exercises/queen-attack/QueenAttack.cs +6 -1
- data/tracks/csharp/exercises/queen-attack/QueenAttackTest.cs +57 -19
- data/tracks/csharp/generators/Exercises/QueenAttack.cs +85 -0
- data/tracks/d/README.md +3 -2
- data/tracks/d/docs/SNIPPET.txt +7 -0
- data/tracks/d/exercises/crypto-square/.dub/dub.json +6 -0
- data/tracks/d/exercises/crypto-square/example/crypto_square.d +4 -2
- data/tracks/dart/exercises/bob/pubspec.lock +28 -16
- data/tracks/dart/exercises/bob/pubspec.yaml +1 -1
- data/tracks/dart/exercises/bob/test/bob_test.dart +2 -0
- data/tracks/dart/exercises/difference-of-squares/pubspec.lock +28 -16
- data/tracks/dart/exercises/difference-of-squares/pubspec.yaml +1 -1
- data/tracks/dart/exercises/gigasecond/pubspec.lock +28 -16
- data/tracks/dart/exercises/gigasecond/pubspec.yaml +1 -1
- data/tracks/dart/exercises/hamming/pubspec.lock +28 -16
- data/tracks/dart/exercises/hamming/pubspec.yaml +1 -1
- data/tracks/dart/exercises/hello-world/pubspec.lock +28 -16
- data/tracks/dart/exercises/hello-world/pubspec.yaml +1 -1
- data/tracks/dart/exercises/hello-world/test/hello_world_test.dart +13 -15
- data/tracks/dart/exercises/leap/pubspec.lock +28 -16
- data/tracks/dart/exercises/leap/pubspec.yaml +1 -1
- data/tracks/dart/exercises/rna-transcription/pubspec.lock +28 -16
- data/tracks/dart/exercises/rna-transcription/pubspec.yaml +1 -1
- data/tracks/elixir/exercises/pig-latin/example.exs +17 -18
- data/tracks/elixir/exercises/pig-latin/pig_latin_test.exs +16 -1
- data/tracks/fsharp/build.cake +0 -2
- data/tracks/go/exercises/error-handling/.meta/description.md +39 -0
- data/tracks/go/exercises/error-handling/.meta/hints.md +5 -0
- data/tracks/go/exercises/error-handling/.meta/metadata.yml +2 -0
- data/tracks/go/exercises/error-handling/README.md +43 -5
- data/tracks/go/exercises/error-handling/common.go +4 -3
- data/tracks/go/exercises/error-handling/error_handling_test.go +1 -38
- data/tracks/go/exercises/secret-handshake/secret_handshake_test.go +3 -1
- data/tracks/haxe/docs/LEARNING.md +8 -0
- data/tracks/java/.gitignore +2 -1
- data/tracks/java/config.json +337 -491
- data/tracks/java/config/maintainers.json +26 -26
- data/tracks/java/exercises/bob/src/test/java/BobTest.java +7 -1
- data/tracks/java/exercises/rna-transcription/src/example/java/RnaTranscription.java +4 -2
- data/tracks/java/exercises/rna-transcription/src/main/java/RnaTranscription.java +5 -3
- data/tracks/java/exercises/rna-transcription/src/test/java/RnaTranscriptionTest.java +21 -26
- data/tracks/javascript/config.json +662 -664
- data/tracks/javascript/config/maintainers.json +35 -35
- data/tracks/javascript/exercises/simple-cipher/simple-cipher.spec.js +7 -3
- data/tracks/plsql/config.json +52 -66
- data/tracks/plsql/docs/SNIPPET.txt +6 -0
- data/tracks/plsql/exercises/hello-world/example.plsql +20 -0
- data/tracks/plsql/exercises/hello-world/hello_world#.plsql +20 -0
- data/tracks/plsql/exercises/hello-world/ut_hello_world#.plsql +60 -0
- data/tracks/sml/Makefile +5 -0
- data/tracks/sml/bin/generate +3 -4
- data/tracks/sml/config.json +55 -5
- data/tracks/sml/exercises/collatz-conjecture/README.md +63 -0
- data/tracks/sml/exercises/collatz-conjecture/collatz-conjecture.sml +4 -0
- data/tracks/sml/exercises/collatz-conjecture/example.sml +17 -0
- data/tracks/sml/exercises/collatz-conjecture/test.sml +30 -0
- data/tracks/sml/exercises/collatz-conjecture/testlib.sml +159 -0
- data/tracks/sml/exercises/leap/README.md +63 -0
- data/tracks/sml/exercises/leap/example.sml +2 -0
- data/tracks/sml/exercises/leap/leap.sml +2 -0
- data/tracks/sml/exercises/leap/test.sml +24 -0
- data/tracks/sml/exercises/leap/testlib.sml +159 -0
- data/tracks/sml/exercises/rna-transcription/README.md +55 -0
- data/tracks/sml/exercises/rna-transcription/example.sml +20 -0
- data/tracks/sml/exercises/rna-transcription/rna-transcription.sml +2 -0
- data/tracks/sml/exercises/rna-transcription/test.sml +36 -0
- data/tracks/sml/exercises/rna-transcription/testlib.sml +159 -0
- data/tracks/sml/exercises/sum-of-multiples/README.md +48 -0
- data/tracks/sml/exercises/sum-of-multiples/example.sml +8 -0
- data/tracks/sml/exercises/sum-of-multiples/sum-of-multiples.sml +2 -0
- data/tracks/sml/exercises/sum-of-multiples/test.sml +48 -0
- data/tracks/sml/exercises/sum-of-multiples/testlib.sml +159 -0
- data/tracks/sml/exercises/two-fer/README.md +78 -0
- data/tracks/sml/exercises/two-fer/example.sml +1 -0
- data/tracks/sml/exercises/two-fer/test.sml +21 -0
- data/tracks/sml/exercises/two-fer/testlib.sml +159 -0
- data/tracks/sml/exercises/two-fer/two-fer.sml +2 -0
- metadata +43 -5
- data/tracks/csharp/exercises/Exercises.All.sln +0 -1545
- data/tracks/csharp/exercises/Exercises.Default.sln +0 -1503
- data/tracks/csharp/exercises/Exercises.Refactoring.sln +0 -61
data/tracks/sml/config.json
CHANGED
@@ -5,9 +5,9 @@
|
|
5
5
|
"test_pattern": "test[.]sml$",
|
6
6
|
"exercises": [
|
7
7
|
{
|
8
|
-
"uuid": "
|
9
|
-
"slug": "
|
10
|
-
"core":
|
8
|
+
"uuid": "4450455d-0786-6f80-7672-48368a115df16e0aa7e",
|
9
|
+
"slug": "hello-world",
|
10
|
+
"core": true,
|
11
11
|
"unlocked_by": null,
|
12
12
|
"difficulty": 1,
|
13
13
|
"topics": [
|
@@ -15,8 +15,8 @@
|
|
15
15
|
]
|
16
16
|
},
|
17
17
|
{
|
18
|
-
"uuid": "
|
19
|
-
"slug": "
|
18
|
+
"uuid": "a56bad29-684c-47e7-9724-8c7f165a51af",
|
19
|
+
"slug": "two-fer",
|
20
20
|
"core": true,
|
21
21
|
"unlocked_by": null,
|
22
22
|
"difficulty": 1,
|
@@ -24,6 +24,26 @@
|
|
24
24
|
|
25
25
|
]
|
26
26
|
},
|
27
|
+
{
|
28
|
+
"uuid": "622644a8-55c3-498e-ac72-ad6d7d31109d",
|
29
|
+
"slug": "leap",
|
30
|
+
"core": true,
|
31
|
+
"unlocked_by": null,
|
32
|
+
"difficulty": 1,
|
33
|
+
"topics": [
|
34
|
+
|
35
|
+
]
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"uuid": "7e1d0e9a-435d-4dc6-8867-2fc4f9b7fe6f",
|
39
|
+
"slug": "all-your-base",
|
40
|
+
"core": false,
|
41
|
+
"unlocked_by": null,
|
42
|
+
"difficulty": 1,
|
43
|
+
"topics": [
|
44
|
+
|
45
|
+
]
|
46
|
+
},
|
27
47
|
{
|
28
48
|
"uuid": "9d8e76f1-0e85-a280-b779-16335f29d1a96ce3a72",
|
29
49
|
"slug": "bob",
|
@@ -164,6 +184,36 @@
|
|
164
184
|
|
165
185
|
]
|
166
186
|
},
|
187
|
+
{
|
188
|
+
"uuid": "db3e09ee-6c93-417f-b0a0-196cdccf4984",
|
189
|
+
"slug": "rna-transcription",
|
190
|
+
"core": false,
|
191
|
+
"unlocked_by": null,
|
192
|
+
"difficulty": 1,
|
193
|
+
"topics": [
|
194
|
+
|
195
|
+
]
|
196
|
+
},
|
197
|
+
{
|
198
|
+
"uuid": "6170f05b-358b-487a-b5ae-4424af422d8e",
|
199
|
+
"slug": "collatz-conjecture",
|
200
|
+
"core": false,
|
201
|
+
"unlocked_by": null,
|
202
|
+
"difficulty": 1,
|
203
|
+
"topics": [
|
204
|
+
|
205
|
+
]
|
206
|
+
},
|
207
|
+
{
|
208
|
+
"uuid": "b9377be8-06c1-5280-33b6-a2071298947c9ddf65e",
|
209
|
+
"slug": "sum-of-multiples",
|
210
|
+
"core": false,
|
211
|
+
"unlocked_by": null,
|
212
|
+
"difficulty": 1,
|
213
|
+
"topics": [
|
214
|
+
|
215
|
+
]
|
216
|
+
},
|
167
217
|
{
|
168
218
|
"uuid": "225cfd7d-81a3-4a58-b1aa-1de2e40e7a93",
|
169
219
|
"slug": "binary",
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Collatz Conjecture
|
2
|
+
|
3
|
+
The Collatz Conjecture or 3x+1 problem can be summarized as follows:
|
4
|
+
|
5
|
+
Take any positive integer n. If n is even, divide n by 2 to get n / 2. If n is
|
6
|
+
odd, multiply n by 3 and add 1 to get 3n + 1. Repeat the process indefinitely.
|
7
|
+
The conjecture states that no matter which number you start with, you will
|
8
|
+
always reach 1 eventually.
|
9
|
+
|
10
|
+
Given a number n, return the number of steps required to reach 1.
|
11
|
+
|
12
|
+
## Examples
|
13
|
+
Starting with n = 12, the steps would be as follows:
|
14
|
+
|
15
|
+
0. 12
|
16
|
+
1. 6
|
17
|
+
2. 3
|
18
|
+
3. 10
|
19
|
+
4. 5
|
20
|
+
5. 16
|
21
|
+
6. 8
|
22
|
+
7. 4
|
23
|
+
8. 2
|
24
|
+
9. 1
|
25
|
+
|
26
|
+
Resulting in 9 steps. So for input n = 12, the return value would be 9.
|
27
|
+
|
28
|
+
|
29
|
+
## Loading your exercise implementation in PolyML
|
30
|
+
|
31
|
+
```
|
32
|
+
$ poly --use {exercise}.sml
|
33
|
+
```
|
34
|
+
|
35
|
+
Or:
|
36
|
+
|
37
|
+
```
|
38
|
+
$ poly
|
39
|
+
> use "{exercise}.sml";
|
40
|
+
```
|
41
|
+
|
42
|
+
**Note:** You have to replace {exercise}.
|
43
|
+
|
44
|
+
## Running the tests
|
45
|
+
|
46
|
+
```
|
47
|
+
$ poly -q --use test.sml
|
48
|
+
```
|
49
|
+
|
50
|
+
## Feedback, Issues, Pull Requests
|
51
|
+
|
52
|
+
The [exercism/sml](https://github.com/exercism/sml) repository on
|
53
|
+
GitHub is the home for all of the Standard ML exercises.
|
54
|
+
|
55
|
+
If you have feedback about an exercise, or want to help implementing a new
|
56
|
+
one, head over there and create an issue. We'll do our best to help you!
|
57
|
+
|
58
|
+
## Source
|
59
|
+
|
60
|
+
An unsolved problem in mathematics named after mathematician Lothar Collatz [https://en.wikipedia.org/wiki/3x_%2B_1_problem](https://en.wikipedia.org/wiki/3x_%2B_1_problem)
|
61
|
+
|
62
|
+
## Submitting Incomplete Solutions
|
63
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
exception NegativeInteger
|
2
|
+
|
3
|
+
fun steps number =
|
4
|
+
let
|
5
|
+
fun odd n = n mod 2 = 1
|
6
|
+
|
7
|
+
fun steps' stepCount n =
|
8
|
+
if n = 1
|
9
|
+
then stepCount
|
10
|
+
else if odd n
|
11
|
+
then steps' (stepCount + 1) (3 * n + 1)
|
12
|
+
else steps' (stepCount + 1) (n div 2)
|
13
|
+
in
|
14
|
+
if number > 0
|
15
|
+
then steps' 0 number
|
16
|
+
else raise NegativeInteger
|
17
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
(* version 1.1.1 *)
|
2
|
+
|
3
|
+
use "testlib.sml";
|
4
|
+
use "collatz-conjecture.sml";
|
5
|
+
|
6
|
+
infixr |>
|
7
|
+
fun x |> f = f x
|
8
|
+
|
9
|
+
val testsuite =
|
10
|
+
describe "collatz-conjecture" [
|
11
|
+
test "zero steps for one"
|
12
|
+
(fn _ => steps (1) |> Expect.equalTo 0),
|
13
|
+
|
14
|
+
test "divide if even"
|
15
|
+
(fn _ => steps (16) |> Expect.equalTo 4),
|
16
|
+
|
17
|
+
test "even and odd steps"
|
18
|
+
(fn _ => steps (12) |> Expect.equalTo 9),
|
19
|
+
|
20
|
+
test "Large number of even and odd steps"
|
21
|
+
(fn _ => steps (1000000) |> Expect.equalTo 152),
|
22
|
+
|
23
|
+
test "zero is an error"
|
24
|
+
(fn _ => (fn _ => steps (0)) |> Expect.error NegativeInteger),
|
25
|
+
|
26
|
+
test "negative value is an error"
|
27
|
+
(fn _ => (fn _ => steps (~15)) |> Expect.error NegativeInteger)
|
28
|
+
]
|
29
|
+
|
30
|
+
val _ = Test.run testsuite
|
@@ -0,0 +1,159 @@
|
|
1
|
+
structure Expect =
|
2
|
+
struct
|
3
|
+
datatype expectation = Pass | Fail of string * string
|
4
|
+
|
5
|
+
local
|
6
|
+
fun failEq b a =
|
7
|
+
Fail ("Expected: " ^ b, "Got: " ^ a)
|
8
|
+
|
9
|
+
fun failExn b a =
|
10
|
+
Fail ("Expected: " ^ b, "Raised: " ^ a)
|
11
|
+
|
12
|
+
fun exnName (e: exn): string = General.exnName e
|
13
|
+
in
|
14
|
+
fun truthy a =
|
15
|
+
if a
|
16
|
+
then Pass
|
17
|
+
else failEq "true" "false"
|
18
|
+
|
19
|
+
fun falsy a =
|
20
|
+
if a
|
21
|
+
then failEq "false" "true"
|
22
|
+
else Pass
|
23
|
+
|
24
|
+
fun equalTo b a =
|
25
|
+
if a = b
|
26
|
+
then Pass
|
27
|
+
else failEq (PolyML.makestring b) (PolyML.makestring a)
|
28
|
+
|
29
|
+
fun nearTo b a =
|
30
|
+
if Real.== (a, b)
|
31
|
+
then Pass
|
32
|
+
else failEq (Real.toString b) (Real.toString a)
|
33
|
+
|
34
|
+
fun anyError f =
|
35
|
+
(
|
36
|
+
f ();
|
37
|
+
failExn "an exception" "Nothing"
|
38
|
+
) handle _ => Pass
|
39
|
+
|
40
|
+
fun error e f =
|
41
|
+
(
|
42
|
+
f ();
|
43
|
+
failExn (exnName e) "Nothing"
|
44
|
+
) handle e' => if exnMessage e' = exnMessage e
|
45
|
+
then Pass
|
46
|
+
else failExn (exnMessage e) (exnMessage e')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
structure TermColor =
|
51
|
+
struct
|
52
|
+
datatype color = Red | Green | Yellow | Normal
|
53
|
+
|
54
|
+
fun f Red = "\027[31m"
|
55
|
+
| f Green = "\027[32m"
|
56
|
+
| f Yellow = "\027[33m"
|
57
|
+
| f Normal = "\027[0m"
|
58
|
+
|
59
|
+
fun colorize color s = (f color) ^ s ^ (f Normal)
|
60
|
+
|
61
|
+
val redit = colorize Red
|
62
|
+
|
63
|
+
val greenit = colorize Green
|
64
|
+
|
65
|
+
val yellowit = colorize Yellow
|
66
|
+
end
|
67
|
+
|
68
|
+
structure Test =
|
69
|
+
struct
|
70
|
+
datatype testnode = TestGroup of string * testnode list
|
71
|
+
| Test of string * (unit -> Expect.expectation)
|
72
|
+
|
73
|
+
local
|
74
|
+
datatype evaluation = Success of string
|
75
|
+
| Failure of string * string * string
|
76
|
+
| Error of string * string
|
77
|
+
|
78
|
+
fun indent n s = (implode (List.tabulate (n, fn _ => #" "))) ^ s
|
79
|
+
|
80
|
+
fun fmt indentlvl ev =
|
81
|
+
let
|
82
|
+
val check = TermColor.greenit "\226\156\148 " (* ✔ *)
|
83
|
+
val cross = TermColor.redit "\226\156\150 " (* ✖ *)
|
84
|
+
val indentlvl = indentlvl * 2
|
85
|
+
in
|
86
|
+
case ev of
|
87
|
+
Success descr => indent indentlvl (check ^ descr)
|
88
|
+
| Failure (descr, exp, got) =>
|
89
|
+
String.concatWith "\n" [indent indentlvl (cross ^ descr),
|
90
|
+
indent (indentlvl + 2) exp,
|
91
|
+
indent (indentlvl + 2) got]
|
92
|
+
| Error (descr, reason) =>
|
93
|
+
String.concatWith "\n" [indent indentlvl (cross ^ descr),
|
94
|
+
indent (indentlvl + 2) (TermColor.redit reason)]
|
95
|
+
end
|
96
|
+
|
97
|
+
fun eval (TestGroup _) = raise Fail "Only a 'Test' can be evaluated"
|
98
|
+
| eval (Test (descr, thunk)) =
|
99
|
+
(
|
100
|
+
case thunk () of
|
101
|
+
Expect.Pass => ((1, 0, 0), Success descr)
|
102
|
+
| Expect.Fail (s, s') => ((0, 1, 0), Failure (descr, s, s'))
|
103
|
+
)
|
104
|
+
handle e => ((0, 0, 1), Error (descr, "Unexpected error: " ^ exnMessage e))
|
105
|
+
|
106
|
+
fun flatten depth testnode =
|
107
|
+
let
|
108
|
+
fun sum (x, y, z) (a, b, c) = (x + a, y + b, z + c)
|
109
|
+
|
110
|
+
fun aux (t, (counter, acc)) =
|
111
|
+
let
|
112
|
+
val (counter', texts) = flatten (depth + 1) t
|
113
|
+
in
|
114
|
+
(sum counter' counter, texts :: acc)
|
115
|
+
end
|
116
|
+
in
|
117
|
+
case testnode of
|
118
|
+
TestGroup (descr, ts) =>
|
119
|
+
let
|
120
|
+
val (counter, texts) = foldr aux ((0, 0, 0), []) ts
|
121
|
+
in
|
122
|
+
(counter, (indent (depth * 2) descr) :: List.concat texts)
|
123
|
+
end
|
124
|
+
| Test _ =>
|
125
|
+
let
|
126
|
+
val (counter, evaluation) = eval testnode
|
127
|
+
in
|
128
|
+
(counter, [fmt depth evaluation])
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
fun println s = print (s ^ "\n")
|
133
|
+
in
|
134
|
+
fun run suite =
|
135
|
+
let
|
136
|
+
val ((succeeded, failed, errored), texts) = flatten 0 suite
|
137
|
+
|
138
|
+
val summary = String.concatWith ", " [
|
139
|
+
TermColor.greenit ((Int.toString succeeded) ^ " passed"),
|
140
|
+
TermColor.redit ((Int.toString failed) ^ " failed"),
|
141
|
+
TermColor.redit ((Int.toString errored) ^ " errored"),
|
142
|
+
(Int.toString (succeeded + failed + errored)) ^ " total"
|
143
|
+
]
|
144
|
+
|
145
|
+
val status = if failed = 0 andalso errored = 0
|
146
|
+
then OS.Process.success
|
147
|
+
else OS.Process.failure
|
148
|
+
|
149
|
+
in
|
150
|
+
List.app println texts;
|
151
|
+
println "";
|
152
|
+
println ("Tests: " ^ summary);
|
153
|
+
OS.Process.exit status
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
fun describe description tests = Test.TestGroup (description, tests)
|
159
|
+
fun test description thunk = Test.Test (description, thunk)
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Leap
|
2
|
+
|
3
|
+
Given a year, report if it is a leap year.
|
4
|
+
|
5
|
+
The tricky thing here is that a leap year in the Gregorian calendar occurs:
|
6
|
+
|
7
|
+
```plain
|
8
|
+
on every year that is evenly divisible by 4
|
9
|
+
except every year that is evenly divisible by 100
|
10
|
+
unless the year is also evenly divisible by 400
|
11
|
+
```
|
12
|
+
|
13
|
+
For example, 1997 is not a leap year, but 1996 is. 1900 is not a leap
|
14
|
+
year, but 2000 is.
|
15
|
+
|
16
|
+
If your language provides a method in the standard library that does
|
17
|
+
this look-up, pretend it doesn't exist and implement it yourself.
|
18
|
+
|
19
|
+
## Notes
|
20
|
+
|
21
|
+
Though our exercise adopts some very simple rules, there is more to
|
22
|
+
learn!
|
23
|
+
|
24
|
+
For a delightful, four minute explanation of the whole leap year
|
25
|
+
phenomenon, go watch [this youtube video][video].
|
26
|
+
|
27
|
+
[video]: http://www.youtube.com/watch?v=xX96xng7sAE
|
28
|
+
|
29
|
+
## Loading your exercise implementation in PolyML
|
30
|
+
|
31
|
+
```
|
32
|
+
$ poly --use {exercise}.sml
|
33
|
+
```
|
34
|
+
|
35
|
+
Or:
|
36
|
+
|
37
|
+
```
|
38
|
+
$ poly
|
39
|
+
> use "{exercise}.sml";
|
40
|
+
```
|
41
|
+
|
42
|
+
**Note:** You have to replace {exercise}.
|
43
|
+
|
44
|
+
## Running the tests
|
45
|
+
|
46
|
+
```
|
47
|
+
$ poly -q --use test.sml
|
48
|
+
```
|
49
|
+
|
50
|
+
## Feedback, Issues, Pull Requests
|
51
|
+
|
52
|
+
The [exercism/sml](https://github.com/exercism/sml) repository on
|
53
|
+
GitHub is the home for all of the Standard ML exercises.
|
54
|
+
|
55
|
+
If you have feedback about an exercise, or want to help implementing a new
|
56
|
+
one, head over there and create an issue. We'll do our best to help you!
|
57
|
+
|
58
|
+
## Source
|
59
|
+
|
60
|
+
JavaRanch Cattle Drive, exercise 3 [http://www.javaranch.com/leap.jsp](http://www.javaranch.com/leap.jsp)
|
61
|
+
|
62
|
+
## Submitting Incomplete Solutions
|
63
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
(* version 1.0.0 *)
|
2
|
+
|
3
|
+
use "testlib.sml";
|
4
|
+
use "leap.sml";
|
5
|
+
|
6
|
+
infixr |>
|
7
|
+
fun x |> f = f x
|
8
|
+
|
9
|
+
val testsuite =
|
10
|
+
describe "leap" [
|
11
|
+
test "year not divisible by 4: common year"
|
12
|
+
(fn _ => leapYear (2015) |> Expect.falsy),
|
13
|
+
|
14
|
+
test "year divisible by 4, not divisible by 100: leap year"
|
15
|
+
(fn _ => leapYear (2016) |> Expect.truthy),
|
16
|
+
|
17
|
+
test "year divisible by 100, not divisible by 400: common year"
|
18
|
+
(fn _ => leapYear (2100) |> Expect.falsy),
|
19
|
+
|
20
|
+
test "year divisible by 400: leap year"
|
21
|
+
(fn _ => leapYear (2000) |> Expect.truthy)
|
22
|
+
]
|
23
|
+
|
24
|
+
val _ = Test.run testsuite
|