-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
fun isPangram (sentence: string): bool = | ||
let | ||
val alphabet = String.explode "qwertyuiopasdfghjklzxcvbnm" | ||
val chars = map Char.toLower (String.explode sentence) | ||
in | ||
List.all (fn letter => List.exists (fn char => char = letter) chars) alphabet | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fun isPangram (sentence: string): bool = | ||
raise Fail "isPangram is not implemented" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use "example.sml"; | ||
|
||
val test_cases = [ | ||
("", false), | ||
("The Quick Brown Fox Jumps Over The Lazy Dog", true), | ||
("the quick brown fox jumps over the lazy dog", true), | ||
("a quick movement of the enemy will jeopardize five gunboats", false), | ||
("the quick brown fish jumps over the lazy dog", false), | ||
("the_quick_brown_fox_jumps_over_the_lazy_dog", true), | ||
("the 1 quick brown fox jumps over the 2 lazy dogs", true), | ||
("7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog", false), | ||
("\"Five quacking Zephyrs jolt my wax bed.\"", true) | ||
(*"Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich.", true*) | ||
(*"Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства.", false*) | ||
]; | ||
|
||
fun run_tests [] = [] | ||
| run_tests ((sentence, expected) :: ts) = | ||
(isPangram sentence = expected) :: run_tests ts | ||
|
||
val allTestsPass = List.foldl (fn (x, y) => x andalso y) true (run_tests test_cases) |