Pangram checker: Difference between revisions

→‎{{header|Julia}}: A new entry for Julia
(example works correctly; thanks for fixing it!)
(→‎{{header|Julia}}: A new entry for Julia)
Line 1,030:
$ jq -M -n -f pangram.jq
true
 
=={{header|Julia}}==
<tt>makepangramchecker</tt> creates a function to test for pangramity based upon the contents of its input string, allowing one to create arbitrary pangram checkers.
<lang Julia>
function makepangramchecker{T<:String}(a::T)
abet = sort(unique(split(uppercase(a), "")))
alen = length(abet)
function ispangram{T<:String}(s::T)
alen <= length(s) || return false
ps = filter(c->(c in abet), unique(split(uppercase(s), "")))
return length(ps) == alen
end
end
 
tests = ["Pack my box with five dozen liquor jugs.",
"The quick brown fox jumps over a lazy dog.",
"The quick brown fox jumps\u2323over the lazy dog.",
"The five boxing wizards jump quickly.",
"This sentence contains A-Z but not the whole alphabet."]
 
isenglishpang = makepangramchecker("abcdefghijklmnopqrstuvwxyz")
 
for s in tests
print("The sentence \"", s, "\" is ")
if !isenglishpang(s)
print("not ")
end
println("a pangram.")
end
</lang>
 
{{out}}
<pre>
The sentence "Pack my box with five dozen liquor jugs." is a pangram.
The sentence "The quick brown fox jumps over a lazy dog." is a pangram.
The sentence "The quick brown fox jumps⌣over the lazy dog." is a pangram.
The sentence "The five boxing wizards jump quickly." is a pangram.
The sentence "This sentence contains A-Z but not the whole alphabet." is not a pangram.
</pre>
 
=={{header|K}}==