Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
37
Task/Pangram-checker/MLite/pangram-checker.mlite
Normal file
37
Task/Pangram-checker/MLite/pangram-checker.mlite
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
fun to_locase s = implode ` map (c_downcase) ` explode s
|
||||
|
||||
fun is_pangram
|
||||
(h :: t, T) =
|
||||
let
|
||||
val flen = len (filter (fn c = c eql h) T)
|
||||
in
|
||||
if (flen = 0) then
|
||||
false
|
||||
else
|
||||
is_pangram (t, T)
|
||||
end
|
||||
| ([], T) = true
|
||||
| S = is_pangram (explode "abcdefghijklmnopqrstuvwxyz", explode ` to_locase S)
|
||||
|
||||
fun is_pangram_i
|
||||
(h :: t, T) =
|
||||
let
|
||||
val flen = len (filter (fn c = c eql h) T)
|
||||
in
|
||||
if (flen = 0) then
|
||||
false
|
||||
else
|
||||
is_pangram (t, T)
|
||||
end
|
||||
| ([], T) = true
|
||||
| (A,S) = is_pangram (explode A, explode ` to_locase S)
|
||||
|
||||
fun test (f, arg, res, ok, notok) = if (f arg eql res) then ("'" @ arg @ "' " @ ok) else ("'" @ arg @ "' " @ notok)
|
||||
fun test2 (f, arg, res, ok, notok) = if (f arg eql res) then ("'" @ ref (arg,1) @ "' " @ ok) else ("'" @ ref (arg,1) @ "' " @ notok)
|
||||
|
||||
;
|
||||
println ` test (is_pangram, "The quick brown fox jumps over the lazy dog", true, "is a pangram", "is not a pangram");
|
||||
println ` test (is_pangram, "abcdefghijklopqrstuvwxyz", true, "is a pangram", "is not a pangram");
|
||||
val SValphabet = "abcdefghijklmnopqrstuvwxyzåäö";
|
||||
val SVsentence = "Yxskaftbud, ge vår wczonmö iq hjälp";
|
||||
println ` test2 (is_pangram_i, (SValphabet, SVsentence), true, "is a Swedish pangram", "is not a Swedish pangram");
|
||||
Loading…
Add table
Add a link
Reference in a new issue