Pangram checker: Difference between revisions

Consolidate BASICs
(→‎{{header|UNIX Shell}}: Make portable across shells, remove unneeded quotes)
(Consolidate BASICs)
Line 1:
[[Category:String manipulation]]
 
{{task}}
{{omit from|Lilypond}}
 
Line 49:
LA R5,1 found
NEXTK LA R11,1(R11) next character
BCT R8,LOOPK
LTR R5,R5 if found
BNZ NEXTJ
Line 55:
B PRINT
NEXTJ LA R10,1(R10) next letter
BCT R7,LOOPJ
MVC BUFFER(2),=CL2'OK'
PRINT MVC BUFFER+3(60),0(R9)
XPRNT BUFFER,80
NEXTI LA R9,60(R9) next sentence
BCT R6,LOOPI
RETURN XR R15,R15
BR R14
Line 69:
DC CL60'PACK MY BOX WITH FIVE DOZEN LIQUOR JUGS.'
BUFFER DC CL80' '
YREGS
END PANGRAM</syntaxhighlight>
{{out}}
Line 153:
var lowerK:String = k.toLowerCase();
var has:Object = {}
 
for (var i:Number=0; i<=k.length-1; i++) {
has[lowerK.charAt(i)] = true;
}
 
var result:Boolean = true;
 
for (var ch:String='a'; ch <= 'z'; ch=String.fromCharCode(ch.charCodeAt(0)+1)) {
result = result && has[ch]
}
 
return result || false;
}</syntaxhighlight>
Line 173:
with Ada.Characters.Handling; use Ada.Characters.Handling;
procedure pangram is
 
function ispangram(txt: String) return Boolean is
(Is_Subset(To_Set(Span => ('a','z')), To_Set(To_Lower(txt))));
 
begin
put_line(Boolean'Image(ispangram("This is a test")));
Line 188:
with Ada.Characters.Handling; use Ada.Characters.Handling;
procedure pangram is
 
function ispangram(txt : in String) return Boolean is
(for all Letter in Character range 'a'..'z' =>
Line 260:
a←'abcdefghijklmnopqrstuvwxyz'
A←'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 
Panagram←{∧/ ∨⌿ 2 26⍴(a,A) ∊ ⍵}
Panagram 'This should fail'
Line 286:
end |λ|
end script
 
0 = length of filter(charUnUsed, ¬
"abcdefghijklmnopqrstuvwxyz")
Line 297:
"is this a pangram", ¬
"The quick brown fox jumps over the lazy dog"})
 
--> {false, true}
end run
Line 331:
 
 
-- Lift 2nd class handler function into
-- 1st class script wrapper
-- mReturn :: Handler -> Script
on mReturn(f)
Line 363:
end repeat
end ignoring
 
return true
end isPangram
Line 513:
for (k=1; k<=length(allChars); k++) {
if (!X[substr(allChars,k,1)]) return 0;
}
return 1;
}</syntaxhighlight>
Line 550:
}
print "# hit:",hit, "# miss:",miss, "." ##
if (miss) return 0
return 1
}</syntaxhighlight>
Line 575:
 
=={{header|BASIC}}==
 
{{works with|QBasic}}
==={{header|BaCon}}===
This can be done in a one-liner.
<syntaxhighlight lang="bacon">DEF FN Pangram(x) = IIF(AMOUNT(UNIQ$(EXPLODE$(EXTRACT$(LCASE$(x), "[^[:alpha:]]", TRUE), 1))) = 26, TRUE, FALSE)
 
PRINT Pangram("The quick brown fox jumps over the lazy dog.")
PRINT Pangram("Jackdaws love my big sphinx of quartz.")
PRINT Pangram("My dog has fleas.")
PRINT Pangram("What's a jackdaw?")
PRINT Pangram("The five boxing wizards jump quickly")</syntaxhighlight>
{{out}}
<pre>1
1
0
0
1
</pre>
 
==={{header|BASIC256}}===
<syntaxhighlight lang="freebasic">function isPangram$(texto$)
longitud = Length(texto$)
if longitud < 26 then return "is not a pangram"
t$ = lower(texto$)
print "'"; texto$; "' ";
for i = 97 to 122
if instr(t$, chr(i)) = 0 then return "is not a pangram"
next i
return "is a pangram"
end function
 
print isPangram$("The quick brown fox jumps over the lazy dog.") # --> true
print isPangram$("The quick brown fox jumped over the lazy dog.") # --> false
print isPangram$("ABC.D.E.FGHI*J/KL-M+NO*PQ R\nSTUVWXYZ") # --> true</syntaxhighlight>
 
==={{header|BBC BASIC}}===
<syntaxhighlight lang="bbcbasic"> FOR test% = 1 TO 2
READ test$
PRINT """" test$ """ " ;
IF FNpangram(test$) THEN
PRINT "is a pangram"
ELSE
PRINT "is not a pangram"
ENDIF
NEXT test%
END
 
DATA "The quick brown fox jumped over the lazy dog"
DATA "The five boxing wizards jump quickly"
 
DEF FNpangram(A$)
LOCAL C%
A$ = FNlower(A$)
FOR C% = ASC("a") TO ASC("z")
IF INSTR(A$, CHR$(C%)) = 0 THEN = FALSE
NEXT
= TRUE
 
DEF FNlower(A$)
LOCAL A%, C%
FOR A% = 1 TO LEN(A$)
C% = ASCMID$(A$,A%)
IF C% >= 65 IF C% <= 90 MID$(A$,A%,1) = CHR$(C%+32)
NEXT
= A$</syntaxhighlight>
{{out}}
<pre>"The quick brown fox jumped over the lazy dog" is not a pangram
"The five boxing wizards jump quickly" is a pangram</pre>
 
String manipulation is expensive, especially in loops, so it may be better to buffer the string and use character values:
 
<pre>DEFFNisPangram(text$)
LOCAL size%,text%,char%,bits%
size%=LENtext$
IF size%<27 THEN =FALSE:REM too few characters
DIM text% LOCAL size%:REM BB4W and RISC OS 5 only
$text%=text$:REM buffer the string
FOR text%=text% TO text%+size%-1:REM each character
char%=?text% OR 32:REM to lower case
IF 96<char% AND char%<123 THEN bits%=bits% OR 1<<(char%-97):REM set ordinal bit
IF bits%=&3FFFFFF THEN =TRUE:REM all ordinal bits set
NEXT text%
=FALSE</pre>
 
==={{header|FreeBASIC}}===
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64
 
Function isPangram(s As Const String) As Boolean
Dim As Integer length = Len(s)
If length < 26 Then Return False
Dim p As String = LCase(s)
For i As Integer = 97 To 122
If Instr(p, Chr(i)) = 0 Then Return False
Next
Return True
End Function
 
Dim s(1 To 3) As String = _
{ _
"The quick brown fox jumps over the lazy dog", _
"abbdefghijklmnopqrstuVwxYz", _ '' no c!
"How vexingly quick daft zebras jump!" _
}
 
For i As Integer = 1 To 3:
Print "'"; s(i); "' is "; IIf(isPangram(s(i)), "a", "not a"); " pangram"
Print
Next
 
Print
Print "Press nay key to quit"
Sleep</syntaxhighlight>
 
{{out}}
<pre>
'The quick brown fox jumps over the lazy dog' is a pangram
 
'abbdefghijklmnopqrstuVwxYz' is not a pangram
 
'How vexingly quick daft zebras jump!' is a pangram
</pre>
 
==={{header|Liberty BASIC}}===
<syntaxhighlight lang="lb">'Returns 0 if the string is NOT a pangram or >0 if it IS a pangram
string$ = "The quick brown fox jumps over the lazy dog."
 
Print isPangram(string$)
 
Function isPangram(string$)
string$ = Lower$(string$)
For i = Asc("a") To Asc("z")
isPangram = Instr(string$, chr$(i))
If isPangram = 0 Then Exit Function
Next i
End Function</syntaxhighlight>
 
==={{header|PureBasic}}===
<syntaxhighlight lang="purebasic">Procedure IsPangram_fast(String$)
String$ = LCase(string$)
char_a=Asc("a")
; sets bits in a variable if a letter is found, reads string only once
For a = 1 To Len(string$)
char$ = Mid(String$, a, 1)
pos = Asc(char$) - char_a
check.l | 1 << pos
Next
If check & $3FFFFFF = $3FFFFFF
ProcedureReturn 1
EndIf
ProcedureReturn 0
EndProcedure
 
Procedure IsPangram_simple(String$)
String$ = LCase(string$)
found = 1
For a = Asc("a") To Asc("z")
; searches for every letter in whole string
If FindString(String$, Chr(a), 0) = 0
found = 0
EndIf
Next
ProcedureReturn found
EndProcedure
 
Debug IsPangram_fast("The quick brown fox jumps over lazy dogs.")
Debug IsPangram_simple("The quick brown fox jumps over lazy dogs.")
Debug IsPangram_fast("No pangram")
Debug IsPangram_simple("No pangram")</syntaxhighlight>
 
 
==={{header|QBasic}}===
 
<syntaxhighlight lang="qbasic">DECLARE FUNCTION IsPangram! (sentence AS STRING)
Line 626 ⟶ 795:
0 What's a jackdaw?
</pre>
 
==={{header|Run BASIC}}===
<syntaxhighlight lang="runbasic">s$ = "The quick brown fox jumps over the lazy dog."
Print pangram(s$);" ";s$
 
s$ = "My dog has fleas."
Print pangram(s$);" ";s$
 
function pangram(str$)
str$ = lower$(str$)
for i = asc("a") to asc("z")
pangram = pangram + (instr(str$, chr$(i)) <> 0)
next i
pangram = (pangram = 26)
end function</syntaxhighlight><pre>1 The quick brown fox jumps over the lazy dog.
0 My dog has fleas.</pre>
 
==={{header|Sinclair ZX81 BASIC}}===
Line 656 ⟶ 841:
<pre>NOT A PANGRAM</pre>
 
==={{header|BaConYabasic}}===
<syntaxhighlight lang="yabasic">sub isPangram$(t$, l1$)
This can be done in a one-liner.
local lt, ll, r$, i, cc, ic
<syntaxhighlight lang="bacon">DEF FN Pangram(x) = IIF(AMOUNT(UNIQ$(EXPLODE$(EXTRACT$(LCASE$(x), "[^[:alpha:]]", TRUE), 1))) = 26, TRUE, FALSE)
 
if numparams = 1 then
PRINT Pangram("The quick brown fox jumps over the lazy dog.")
l1$ = "abcdefghijklmnopqrstuvwxyz"
PRINT Pangram("Jackdaws love my big sphinx of quartz.")
end if
PRINT Pangram("My dog has fleas.")
PRINT Pangram("What's a jackdaw?")
PRINT Pangram("The five boxing wizards jump quickly")</syntaxhighlight>
{{out}}
<pre>1
1
0
0
1
</pre>
 
t$ = lower$(t$)
ll = len(l1$)
for i = 1 to ll
r$ = r$ + " "
next
lt = len(t$)
cc = asc("a")
 
for i = 1 to lt
=={{header|BASIC256}}==
ic = asc(mid$(t$, i, 1)) - cc + 1
<syntaxhighlight lang="freebasic">function isPangram$(texto$)
if ic > 0 and ic <= ll then
longitud = Length(texto$)
mid$(r$, ic, 1) = chr$(ic + cc - 1)
if longitud < 26 then return "is not a pangram"
end if
t$ = lower(texto$)
next i
print "'"; texto$; "' ";
for i = 97 to 122
if instr(t$, chr(i)) = 0 then return "is not a pangram"
next i
return "is a pangram"
end function
 
if l1$ = r$ then return "true" else return "false" end if
print isPangram$("The quick brown fox jumps over the lazy dog.") # --> true
print isPangram$("The quick brown fox jumped over the lazy dog.") # --> false
print isPangram$("ABC.D.E.FGHI*J/KL-M+NO*PQ R\nSTUVWXYZ") # --> true</syntaxhighlight>
 
end sub
 
print isPangram$("The quick brown fox jumps over the lazy dog.") // --> true
print isPangram$("The quick brown fox jumped over the lazy dog.") // --> false
print isPangram$("ABC.D.E.FGHI*J/KL-M+NO*PQ R\nSTUVWXYZ") // --> true</syntaxhighlight>
 
=={{header|Batch File}}==
Line 727 ⟶ 908:
 
Press any key to continue . . .</pre>
 
=={{header|BBC BASIC}}==
<syntaxhighlight lang="bbcbasic"> FOR test% = 1 TO 2
READ test$
PRINT """" test$ """ " ;
IF FNpangram(test$) THEN
PRINT "is a pangram"
ELSE
PRINT "is not a pangram"
ENDIF
NEXT test%
END
DATA "The quick brown fox jumped over the lazy dog"
DATA "The five boxing wizards jump quickly"
DEF FNpangram(A$)
LOCAL C%
A$ = FNlower(A$)
FOR C% = ASC("a") TO ASC("z")
IF INSTR(A$, CHR$(C%)) = 0 THEN = FALSE
NEXT
= TRUE
DEF FNlower(A$)
LOCAL A%, C%
FOR A% = 1 TO LEN(A$)
C% = ASCMID$(A$,A%)
IF C% >= 65 IF C% <= 90 MID$(A$,A%,1) = CHR$(C%+32)
NEXT
= A$</syntaxhighlight>
{{out}}
<pre>"The quick brown fox jumped over the lazy dog" is not a pangram
"The five boxing wizards jump quickly" is a pangram</pre>
 
String manipulation is expensive, especially in loops, so it may be better to buffer the string and use character values:
 
<pre>DEFFNisPangram(text$)
LOCAL size%,text%,char%,bits%
size%=LENtext$
IF size%<27 THEN =FALSE:REM too few characters
DIM text% LOCAL size%:REM BB4W and RISC OS 5 only
$text%=text$:REM buffer the string
FOR text%=text% TO text%+size%-1:REM each character
char%=?text% OR 32:REM to lower case
IF 96<char% AND char%<123 THEN bits%=bits% OR 1<<(char%-97):REM set ordinal bit
IF bits%=&3FFFFFF THEN =TRUE:REM all ordinal bits set
NEXT text%
=FALSE</pre>
 
=={{header|BCPL}}==
Line 835 ⟶ 967:
)
& !k:>z
&
);</syntaxhighlight>
Some examples:
Line 1,039 ⟶ 1,171:
=={{header|Ceylon}}==
<syntaxhighlight lang="ceylon">shared void run() {
 
function pangram(String sentence) =>
let(alphabet = set('a'..'z'),
Line 1,065 ⟶ 1,197:
letters: array[bool] := array[bool]$fill(0,26,false)
for c: char in string$chars(s) do
if c>='a' & c<='z' then
c := char$i2c(char$c2i(c) - 32)
end
Line 1,085 ⟶ 1,217:
"abcdefghijklmnopqrstuvwxyz"
]
 
for example: string in array[string]$elements(examples) do
stream$puts(po, "\"" || example || "\" is")
Line 1,163 ⟶ 1,295:
for i in [a_code...a_code+26]
required_letters[String.fromCharCode(i)] = true
 
cnt = 0
for c in s
Line 1,224 ⟶ 1,356:
 
PROCEDURE Check(str: ARRAY OF CHAR): BOOLEAN;
CONST
letters = 26;
VAR
i,j: INTEGER;
status: ARRAY letters OF BOOLEAN;
resp : BOOLEAN;
BEGIN
FOR i := 0 TO LEN(status) -1 DO status[i] := FALSE END;
 
FOR i := 0 TO LEN(str) - 1 DO
j := ORD(CAP(str[i])) - ORD('A');
IF (0 <= j) & (25 >= j) & ~status[j] THEN status[j] := TRUE END
END;
 
resp := TRUE;
FOR i := 0 TO LEN(status) - 1 DO;
Line 1,285 ⟶ 1,417:
var letters: uint8[26];
MemZero(&letters[0], 26);
 
loop
var chr := [str];
Line 1,294 ⟶ 1,426:
letters[chr] := letters[chr] | 1;
end loop;
 
r := 1;
chr := 0;
Line 1,329 ⟶ 1,461:
('a'..'z').all? {|c| sentence.downcase.includes?(c) }
end
 
p pangram?("not a pangram")
p pangram?("The quick brown fox jumps over the lazy dog.")</syntaxhighlight>
Line 1,414 ⟶ 1,546:
byte A = pretend('a', byte);
byte Z = pretend('z', byte);
 
letters := 0L0;
while
Line 1,430 ⟶ 1,562:
 
proc nonrec test(*char s) void:
writeln("\"", s, "\": ",
if pangram(s) then "yes" else "no" fi)
corp
Line 1,653 ⟶ 1,785:
)</syntaxhighlight>
{{Out}}
{| class="wikitable"
|-
|||style="text-align:right; font-family:serif; font-style:italic; font-size:120%;"|fx
! colspan="2" style="text-align:left; vertical-align: bottom; font-family:Arial, Helvetica, sans-serif !important;"|=ISPANGRAM(A2)
|- style="text-align:center; font-family:Arial, Helvetica, sans-serif !important; background-color:#000000; color:#ffffff;"
|
| A
| B
|- style="text-align:left;"
| style="text-align:center; font-family:Arial, Helvetica, sans-serif !important; background-color:#000000; color:#ffffff" | 1
| style="text-align:right; font-weight:bold" | Test strings
| style="font-weight:bold" | Verdicts
|- style="text-align:right;"
| style="text-align:center; font-family:Arial, Helvetica, sans-serif !important; background-color:#000000; color:#ffffff" | 2
| style="text-align:right;" | The quick brown fox jumps over the lazy dog
| style="background-color:#cbcefb; text-align:left; " | TRUE
|- style="text-align:right;"
| style="text-align:center; font-family:Arial, Helvetica, sans-serif !important; background-color:#000000; color:#ffffff" | 3
| style="text-align:right;" | Is this a pangram
| style="text-align:left; | FALSE
|- style="text-align:right;"
| style="text-align:center; font-family:Arial, Helvetica, sans-serif !important; background-color:#000000; color:#ffffff" | 4
| style="text-align:right;" | How vexingly quick daft zebras jump!
| style="text-align:left;" | TRUE
|- style="text-align:right;"
| style="text-align:center; font-family:Arial, Helvetica, sans-serif !important; background-color:#000000; color:#ffffff" | 5
| style="text-align:right;" | The five boxing wizards jumped quickly.
| style="text-align:left;| TRUE
|}
Line 1,778 ⟶ 1,910:
The five boxing wizards jumped quickly.
T</pre>
 
=={{header|FreeBASIC}}==
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64
 
Function isPangram(s As Const String) As Boolean
Dim As Integer length = Len(s)
If length < 26 Then Return False
Dim p As String = LCase(s)
For i As Integer = 97 To 122
If Instr(p, Chr(i)) = 0 Then Return False
Next
Return True
End Function
 
Dim s(1 To 3) As String = _
{ _
"The quick brown fox jumps over the lazy dog", _
"abbdefghijklmnopqrstuVwxYz", _ '' no c!
"How vexingly quick daft zebras jump!" _
}
 
For i As Integer = 1 To 3:
Print "'"; s(i); "' is "; IIf(isPangram(s(i)), "a", "not a"); " pangram"
Print
Next
 
Print
Print "Press nay key to quit"
Sleep</syntaxhighlight>
 
{{out}}
<pre>
'The quick brown fox jumps over the lazy dog' is a pangram
 
'abbdefghijklmnopqrstuVwxYz' is not a pangram
 
'How vexingly quick daft zebras jump!' is a pangram
</pre>
 
=={{header|Frink}}==
Line 1,909 ⟶ 2,003:
 
=={{header|Icon}} and {{header|Unicon}}==
A panagram procedure:
<syntaxhighlight lang="icon">procedure panagram(s) #: return s if s is a panagram and fail otherwise
if (map(s) ** &lcase) === &lcase then return s
Line 1,918 ⟶ 2,012:
 
if *arglist > 0 then
every ( s := "" ) ||:= !arglist || " "
else
s := "The quick brown fox jumps over the lazy dog."
 
writes(image(s), " -- is")
writes(if not panagram(s) then "n't")
write(" a panagram.")
end</syntaxhighlight>
 
Line 2,111 ⟶ 2,205:
if (c !in t) return false
return true
}
 
fun main(args: Array<String>) {
Line 2,120 ⟶ 2,214:
"A very mad quack might jinx zippy fowls" // no 'b' now!
)
for (candidate in candidates)
println("'$candidate' is ${if (isPangram(candidate)) "a" else "not a"} pangram")
}</syntaxhighlight>
Line 2,180 ⟶ 2,274:
A very mad quack might jinx zippy fowls. <<< Is not a pangram.
</pre>
 
=={{header|Liberty BASIC}}==
<syntaxhighlight lang="lb">'Returns 0 if the string is NOT a pangram or >0 if it IS a pangram
string$ = "The quick brown fox jumps over the lazy dog."
 
Print isPangram(string$)
 
Function isPangram(string$)
string$ = Lower$(string$)
For i = Asc("a") To Asc("z")
isPangram = Instr(string$, chr$(i))
If isPangram = 0 Then Exit Function
Next i
End Function</syntaxhighlight>
 
=={{header|Logo}}==
Line 2,245 ⟶ 2,325:
 
Or a slightly more verbose version that outputs the missing characters if the string is not a pangram:
<syntaxhighlight lang="mathematica">pangramQ[msg_] :=
Function[If[# === {}, Print["The string is a pangram!"],
Print["The string is not a pangram. It's missing the letters " <>
ToString[#]]]][
Complement[CharacterRange["a", "z"], Characters[ToLowerCase[msg]]]]</syntaxhighlight>
Line 2,278 ⟶ 2,358:
 
=={{header|MATLAB}} / {{header|Octave}}==
 
<syntaxhighlight lang="matlab">function trueFalse = isPangram(string)
% X is a histogram of letters
Line 2,301 ⟶ 2,381:
"Peter Piper picked a peck of pickled peppers.",
"Waltz job vexed quick frog nymphs."]
 
alphabet = "abcdefghijklmnopqrstuvwxyz"
 
pangram = function (toCheck)
sentence = toCheck.lower
Line 2,312 ⟶ 2,392:
return true
end function
 
for sentence in sentences
if pangram(sentence) then
print """" + sentence + """ is a Pangram"
else
print """" + sentence + """ is not a Pangram"
end if
Line 2,331 ⟶ 2,411:
<syntaxhighlight lang="ocaml">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
Line 2,341 ⟶ 2,421:
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
Line 2,354 ⟶ 2,434:
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");
</syntaxhighlight>
{{out}}
Line 2,623 ⟶ 2,703:
<span style="color: #008080;">return</span> <span style="color: #0000FF;">{</span><span style="color: #004600;">false</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">find</span><span style="color: #0000FF;">(</span><span style="color: #004600;">false</span><span style="color: #0000FF;">,</span><span style="color: #000000;">az</span><span style="color: #0000FF;">)+</span><span style="color: #000000;">96</span><span style="color: #0000FF;">}</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
 
<span style="color: #004080;">sequence</span> <span style="color: #000000;">checks</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #008000;">"The quick brown fox jumped over the lazy dog"</span><span style="color: #0000FF;">,</span>
<span style="color: #008000;">"The quick brown fox jumps over the lazy dog"</span><span style="color: #0000FF;">,</span>
Line 2,742 ⟶ 2,822:
<syntaxhighlight lang="picat">go =>
S1 = "The quick brown fox jumps over the lazy dog",
S2 = "The slow brown fox jumps over the lazy dog",
println([S1, is_pangram(S1)]),
println([S2, is_pangram(S2)]),
Line 2,811 ⟶ 2,891:
{{out}}
<pre>
Please type a sentence
 
the quick brown fox jumps over the lazy dog
The sentence is a pangram.
</pre>
 
Line 2,825 ⟶ 2,905:
$Text = $Text.ToLower()
$Alphabet = $Alphabet.ToLower()
 
$IsPangram = @( $Alphabet.ToCharArray() | Where-Object { $Text.Contains( $_ ) } ).Count -eq $Alphabet.Length
 
return $IsPangram
}
 
Test-Pangram 'The quick brown fox jumped over the lazy dog.'
Test-Pangram 'The quick brown fox jumps over the lazy dog.'
Line 2,872 ⟶ 2,952:
{{out}}
<pre>?- pangram_example.
the quick brown fox jumps over the lazy dog --> ok
the quick brown fox jumped over the lazy dog --> ko
true.</pre>
 
=={{header|PureBasic}}==
<syntaxhighlight lang="purebasic">Procedure IsPangram_fast(String$)
String$ = LCase(string$)
char_a=Asc("a")
; sets bits in a variable if a letter is found, reads string only once
For a = 1 To Len(string$)
char$ = Mid(String$, a, 1)
pos = Asc(char$) - char_a
check.l | 1 << pos
Next
If check & $3FFFFFF = $3FFFFFF
ProcedureReturn 1
EndIf
ProcedureReturn 0
EndProcedure
 
Procedure IsPangram_simple(String$)
String$ = LCase(string$)
found = 1
For a = Asc("a") To Asc("z")
; searches for every letter in whole string
If FindString(String$, Chr(a), 0) = 0
found = 0
EndIf
Next
ProcedureReturn found
EndProcedure
 
Debug IsPangram_fast("The quick brown fox jumps over lazy dogs.")
Debug IsPangram_simple("The quick brown fox jumps over lazy dogs.")
Debug IsPangram_fast("No pangram")
Debug IsPangram_simple("No pangram")</syntaxhighlight>
 
=={{header|Python}}==
Line 2,947 ⟶ 2,994:
my.letters <- tolower(unlist(strsplit(sentence, "")))
is.pangram <- all(letters %in% my.letters)
 
if (is.pangram){
cat("\"", sentence, "\" is a pangram! \n", sep="")
Line 3,035 ⟶ 3,082:
 
──────── Please enter a pangramic sentence (or a blank to quit):
◄■■■■■■■■■■ user input (null or some blanks).
 
──────── PANGRAM program ended. ────────
Line 3,045 ⟶ 3,092:
s = "The quick brown fox jumps over the lazy dog."
see "" + pangram(s) + " " + s + nl
 
s = "My dog has fleas."
see "" + pangram(s) + " " + s + nl
 
func pangram str
str = lower(str)
Line 3,054 ⟶ 3,101:
bool = substr(str, char(i)) > 0
pangram = pangram + bool
next
pan = (pangram = 26)
return pan
Line 3,067 ⟶ 3,114:
p pangram?('this is a sentence') # ==> false
p pangram?('The quick brown fox jumps over the lazy dog.') # ==> true</syntaxhighlight>
 
=={{header|Run BASIC}}==
<syntaxhighlight lang="runbasic">s$ = "The quick brown fox jumps over the lazy dog."
Print pangram(s$);" ";s$
 
s$ = "My dog has fleas."
Print pangram(s$);" ";s$
function pangram(str$)
str$ = lower$(str$)
for i = asc("a") to asc("z")
pangram = pangram + (instr(str$, chr$(i)) <> 0)
next i
pangram = (pangram = 26)
end function</syntaxhighlight><pre>1 The quick brown fox jumps over the lazy dog.
0 My dog has fleas.</pre>
 
=={{header|Rust}}==
Line 3,250 ⟶ 3,281:
 
define('panchk(str)tf') :(panchk_end)
panchk output = str
tf = 'False'; tf = pangram(str) 'True'
output = 'Pangram: ' tf :(return)
Line 3,377 ⟶ 3,408:
#cast %bL
 
test =
 
is_pangram* <
Line 3,398 ⟶ 3,429:
Dim sLow As String
Dim i As Integer
 
sLow = LCase(s)
For i = 1 To 26
Line 3,439 ⟶ 3,470:
pangram = ( ltrim(sKey) = vbnullstring )
end function
 
function eef( bCond, exp1, exp2 )
if bCond then
Line 3,563 ⟶ 3,594:
no
</pre>
 
=={{header|Yabasic}}==
<syntaxhighlight lang="yabasic">sub isPangram$(t$, l1$)
local lt, ll, r$, i, cc, ic
if numparams = 1 then
l1$ = "abcdefghijklmnopqrstuvwxyz"
end if
t$ = lower$(t$)
ll = len(l1$)
for i = 1 to ll
r$ = r$ + " "
next
lt = len(t$)
cc = asc("a")
for i = 1 to lt
ic = asc(mid$(t$, i, 1)) - cc + 1
if ic > 0 and ic <= ll then
mid$(r$, ic, 1) = chr$(ic + cc - 1)
end if
next i
 
if l1$ = r$ then return "true" else return "false" end if
 
end sub
 
print isPangram$("The quick brown fox jumps over the lazy dog.") // --> true
print isPangram$("The quick brown fox jumped over the lazy dog.") // --> false
print isPangram$("ABC.D.E.FGHI*J/KL-M+NO*PQ R\nSTUVWXYZ") // --> true</syntaxhighlight>
 
=={{header|zkl}}==
1,481

edits