Pangram checker: Difference between revisions

Content added Content deleted
(→‎{{header|UNIX Shell}}: Make portable across shells, remove unneeded quotes)
(Consolidate BASICs)
Line 1: Line 1:
[[Category:String manipulation]]
[[Category:String manipulation]]


{{task}}
{{task}}
{{omit from|Lilypond}}
{{omit from|Lilypond}}


Line 49: Line 49:
LA R5,1 found
LA R5,1 found
NEXTK LA R11,1(R11) next character
NEXTK LA R11,1(R11) next character
BCT R8,LOOPK
BCT R8,LOOPK
LTR R5,R5 if found
LTR R5,R5 if found
BNZ NEXTJ
BNZ NEXTJ
Line 55: Line 55:
B PRINT
B PRINT
NEXTJ LA R10,1(R10) next letter
NEXTJ LA R10,1(R10) next letter
BCT R7,LOOPJ
BCT R7,LOOPJ
MVC BUFFER(2),=CL2'OK'
MVC BUFFER(2),=CL2'OK'
PRINT MVC BUFFER+3(60),0(R9)
PRINT MVC BUFFER+3(60),0(R9)
XPRNT BUFFER,80
XPRNT BUFFER,80
NEXTI LA R9,60(R9) next sentence
NEXTI LA R9,60(R9) next sentence
BCT R6,LOOPI
BCT R6,LOOPI
RETURN XR R15,R15
RETURN XR R15,R15
BR R14
BR R14
Line 69: Line 69:
DC CL60'PACK MY BOX WITH FIVE DOZEN LIQUOR JUGS.'
DC CL60'PACK MY BOX WITH FIVE DOZEN LIQUOR JUGS.'
BUFFER DC CL80' '
BUFFER DC CL80' '
YREGS
YREGS
END PANGRAM</syntaxhighlight>
END PANGRAM</syntaxhighlight>
{{out}}
{{out}}
Line 153: Line 153:
var lowerK:String = k.toLowerCase();
var lowerK:String = k.toLowerCase();
var has:Object = {}
var has:Object = {}

for (var i:Number=0; i<=k.length-1; i++) {
for (var i:Number=0; i<=k.length-1; i++) {
has[lowerK.charAt(i)] = true;
has[lowerK.charAt(i)] = true;
}
}

var result:Boolean = true;
var result:Boolean = true;

for (var ch:String='a'; ch <= 'z'; ch=String.fromCharCode(ch.charCodeAt(0)+1)) {
for (var ch:String='a'; ch <= 'z'; ch=String.fromCharCode(ch.charCodeAt(0)+1)) {
result = result && has[ch]
result = result && has[ch]
}
}

return result || false;
return result || false;
}</syntaxhighlight>
}</syntaxhighlight>
Line 173: Line 173:
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Characters.Handling; use Ada.Characters.Handling;
procedure pangram is
procedure pangram is

function ispangram(txt: String) return Boolean is
function ispangram(txt: String) return Boolean is
(Is_Subset(To_Set(Span => ('a','z')), To_Set(To_Lower(txt))));
(Is_Subset(To_Set(Span => ('a','z')), To_Set(To_Lower(txt))));

begin
begin
put_line(Boolean'Image(ispangram("This is a test")));
put_line(Boolean'Image(ispangram("This is a test")));
Line 188: Line 188:
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Characters.Handling; use Ada.Characters.Handling;
procedure pangram is
procedure pangram is

function ispangram(txt : in String) return Boolean is
function ispangram(txt : in String) return Boolean is
(for all Letter in Character range 'a'..'z' =>
(for all Letter in Character range 'a'..'z' =>
Line 260: Line 260:
a←'abcdefghijklmnopqrstuvwxyz'
a←'abcdefghijklmnopqrstuvwxyz'
A←'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
A←'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

Panagram←{∧/ ∨⌿ 2 26⍴(a,A) ∊ ⍵}
Panagram←{∧/ ∨⌿ 2 26⍴(a,A) ∊ ⍵}
Panagram 'This should fail'
Panagram 'This should fail'
Line 286: Line 286:
end |λ|
end |λ|
end script
end script

0 = length of filter(charUnUsed, ¬
0 = length of filter(charUnUsed, ¬
"abcdefghijklmnopqrstuvwxyz")
"abcdefghijklmnopqrstuvwxyz")
Line 297: Line 297:
"is this a pangram", ¬
"is this a pangram", ¬
"The quick brown fox jumps over the lazy dog"})
"The quick brown fox jumps over the lazy dog"})

--> {false, true}
--> {false, true}
end run
end run
Line 331: Line 331:




-- Lift 2nd class handler function into
-- Lift 2nd class handler function into
-- 1st class script wrapper
-- 1st class script wrapper
-- mReturn :: Handler -> Script
-- mReturn :: Handler -> Script
on mReturn(f)
on mReturn(f)
Line 363: Line 363:
end repeat
end repeat
end ignoring
end ignoring

return true
return true
end isPangram
end isPangram
Line 513: Line 513:
for (k=1; k<=length(allChars); k++) {
for (k=1; k<=length(allChars); k++) {
if (!X[substr(allChars,k,1)]) return 0;
if (!X[substr(allChars,k,1)]) return 0;
}
}
return 1;
return 1;
}</syntaxhighlight>
}</syntaxhighlight>
Line 550: Line 550:
}
}
print "# hit:",hit, "# miss:",miss, "." ##
print "# hit:",hit, "# miss:",miss, "." ##
if (miss) return 0
if (miss) return 0
return 1
return 1
}</syntaxhighlight>
}</syntaxhighlight>
Line 575: Line 575:


=={{header|BASIC}}==
=={{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)
<syntaxhighlight lang="qbasic">DECLARE FUNCTION IsPangram! (sentence AS STRING)
Line 626: Line 795:
0 What's a jackdaw?
0 What's a jackdaw?
</pre>
</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}}===
==={{header|Sinclair ZX81 BASIC}}===
Line 656: Line 841:
<pre>NOT A PANGRAM</pre>
<pre>NOT A PANGRAM</pre>


==={{header|BaCon}}===
==={{header|Yabasic}}===
<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}}==
=={{header|Batch File}}==
Line 727: Line 908:


Press any key to continue . . .</pre>
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}}==
=={{header|BCPL}}==
Line 835: Line 967:
)
)
& !k:>z
& !k:>z
&
&
);</syntaxhighlight>
);</syntaxhighlight>
Some examples:
Some examples:
Line 1,039: Line 1,171:
=={{header|Ceylon}}==
=={{header|Ceylon}}==
<syntaxhighlight lang="ceylon">shared void run() {
<syntaxhighlight lang="ceylon">shared void run() {

function pangram(String sentence) =>
function pangram(String sentence) =>
let(alphabet = set('a'..'z'),
let(alphabet = set('a'..'z'),
Line 1,065: Line 1,197:
letters: array[bool] := array[bool]$fill(0,26,false)
letters: array[bool] := array[bool]$fill(0,26,false)
for c: char in string$chars(s) do
for c: char in string$chars(s) do
if c>='a' & c<='z' then
if c>='a' & c<='z' then
c := char$i2c(char$c2i(c) - 32)
c := char$i2c(char$c2i(c) - 32)
end
end
Line 1,085: Line 1,217:
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
]
]

for example: string in array[string]$elements(examples) do
for example: string in array[string]$elements(examples) do
stream$puts(po, "\"" || example || "\" is")
stream$puts(po, "\"" || example || "\" is")
Line 1,163: Line 1,295:
for i in [a_code...a_code+26]
for i in [a_code...a_code+26]
required_letters[String.fromCharCode(i)] = true
required_letters[String.fromCharCode(i)] = true

cnt = 0
cnt = 0
for c in s
for c in s
Line 1,224: Line 1,356:


PROCEDURE Check(str: ARRAY OF CHAR): BOOLEAN;
PROCEDURE Check(str: ARRAY OF CHAR): BOOLEAN;
CONST
CONST
letters = 26;
letters = 26;
VAR
VAR
i,j: INTEGER;
i,j: INTEGER;
status: ARRAY letters OF BOOLEAN;
status: ARRAY letters OF BOOLEAN;
resp : BOOLEAN;
resp : BOOLEAN;
BEGIN
BEGIN
FOR i := 0 TO LEN(status) -1 DO status[i] := FALSE END;
FOR i := 0 TO LEN(status) -1 DO status[i] := FALSE END;

FOR i := 0 TO LEN(str) - 1 DO
FOR i := 0 TO LEN(str) - 1 DO
j := ORD(CAP(str[i])) - ORD('A');
j := ORD(CAP(str[i])) - ORD('A');
IF (0 <= j) & (25 >= j) & ~status[j] THEN status[j] := TRUE END
IF (0 <= j) & (25 >= j) & ~status[j] THEN status[j] := TRUE END
END;
END;

resp := TRUE;
resp := TRUE;
FOR i := 0 TO LEN(status) - 1 DO;
FOR i := 0 TO LEN(status) - 1 DO;
Line 1,285: Line 1,417:
var letters: uint8[26];
var letters: uint8[26];
MemZero(&letters[0], 26);
MemZero(&letters[0], 26);

loop
loop
var chr := [str];
var chr := [str];
Line 1,294: Line 1,426:
letters[chr] := letters[chr] | 1;
letters[chr] := letters[chr] | 1;
end loop;
end loop;

r := 1;
r := 1;
chr := 0;
chr := 0;
Line 1,329: Line 1,461:
('a'..'z').all? {|c| sentence.downcase.includes?(c) }
('a'..'z').all? {|c| sentence.downcase.includes?(c) }
end
end

p pangram?("not a pangram")
p pangram?("not a pangram")
p pangram?("The quick brown fox jumps over the lazy dog.")</syntaxhighlight>
p pangram?("The quick brown fox jumps over the lazy dog.")</syntaxhighlight>
Line 1,414: Line 1,546:
byte A = pretend('a', byte);
byte A = pretend('a', byte);
byte Z = pretend('z', byte);
byte Z = pretend('z', byte);

letters := 0L0;
letters := 0L0;
while
while
Line 1,430: Line 1,562:


proc nonrec test(*char s) void:
proc nonrec test(*char s) void:
writeln("\"", s, "\": ",
writeln("\"", s, "\": ",
if pangram(s) then "yes" else "no" fi)
if pangram(s) then "yes" else "no" fi)
corp
corp
Line 1,653: Line 1,785:
)</syntaxhighlight>
)</syntaxhighlight>
{{Out}}
{{Out}}
{| class="wikitable"
{| class="wikitable"
|-
|-
|||style="text-align:right; font-family:serif; font-style:italic; font-size:120%;"|fx
|||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)
! 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;"
|- style="text-align:center; font-family:Arial, Helvetica, sans-serif !important; background-color:#000000; color:#ffffff;"
|
|
| A
| A
| B
| B
|- style="text-align:left;"
|- style="text-align:left;"
| style="text-align:center; font-family:Arial, Helvetica, sans-serif !important; background-color:#000000; color:#ffffff" | 1
| 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="text-align:right; font-weight:bold" | Test strings
| style="font-weight:bold" | Verdicts
| style="font-weight:bold" | Verdicts
|- style="text-align:right;"
|- style="text-align:right;"
| style="text-align:center; font-family:Arial, Helvetica, sans-serif !important; background-color:#000000; color:#ffffff" | 2
| 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="text-align:right;" | The quick brown fox jumps over the lazy dog
| style="background-color:#cbcefb; text-align:left; " | TRUE
| style="background-color:#cbcefb; text-align:left; " | TRUE
|- style="text-align:right;"
|- style="text-align:right;"
| style="text-align:center; font-family:Arial, Helvetica, sans-serif !important; background-color:#000000; color:#ffffff" | 3
| 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:right;" | Is this a pangram
| style="text-align:left; | FALSE
| style="text-align:left; | FALSE
|- style="text-align:right;"
|- style="text-align:right;"
| style="text-align:center; font-family:Arial, Helvetica, sans-serif !important; background-color:#000000; color:#ffffff" | 4
| 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:right;" | How vexingly quick daft zebras jump!
| style="text-align:left;" | TRUE
| style="text-align:left;" | TRUE
|- style="text-align:right;"
|- style="text-align:right;"
| style="text-align:center; font-family:Arial, Helvetica, sans-serif !important; background-color:#000000; color:#ffffff" | 5
| 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:right;" | The five boxing wizards jumped quickly.
| style="text-align:left;| TRUE
| style="text-align:left;| TRUE
|}
|}
Line 1,778: Line 1,910:
The five boxing wizards jumped quickly.
The five boxing wizards jumped quickly.
T</pre>
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}}==
=={{header|Frink}}==
Line 1,909: Line 2,003:


=={{header|Icon}} and {{header|Unicon}}==
=={{header|Icon}} and {{header|Unicon}}==
A panagram procedure:
A panagram procedure:
<syntaxhighlight lang="icon">procedure panagram(s) #: return s if s is a panagram and fail otherwise
<syntaxhighlight lang="icon">procedure panagram(s) #: return s if s is a panagram and fail otherwise
if (map(s) ** &lcase) === &lcase then return s
if (map(s) ** &lcase) === &lcase then return s
Line 1,918: Line 2,012:


if *arglist > 0 then
if *arglist > 0 then
every ( s := "" ) ||:= !arglist || " "
every ( s := "" ) ||:= !arglist || " "
else
else
s := "The quick brown fox jumps over the lazy dog."
s := "The quick brown fox jumps over the lazy dog."


writes(image(s), " -- is")
writes(image(s), " -- is")
writes(if not panagram(s) then "n't")
writes(if not panagram(s) then "n't")
write(" a panagram.")
write(" a panagram.")
end</syntaxhighlight>
end</syntaxhighlight>


Line 2,111: Line 2,205:
if (c !in t) return false
if (c !in t) return false
return true
return true
}
}


fun main(args: Array<String>) {
fun main(args: Array<String>) {
Line 2,120: Line 2,214:
"A very mad quack might jinx zippy fowls" // no 'b' now!
"A very mad quack might jinx zippy fowls" // no 'b' now!
)
)
for (candidate in candidates)
for (candidate in candidates)
println("'$candidate' is ${if (isPangram(candidate)) "a" else "not a"} pangram")
println("'$candidate' is ${if (isPangram(candidate)) "a" else "not a"} pangram")
}</syntaxhighlight>
}</syntaxhighlight>
Line 2,180: Line 2,274:
A very mad quack might jinx zippy fowls. <<< Is not a pangram.
A very mad quack might jinx zippy fowls. <<< Is not a pangram.
</pre>
</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}}==
=={{header|Logo}}==
Line 2,245: Line 2,325:


Or a slightly more verbose version that outputs the missing characters if the string is not a pangram:
Or a slightly more verbose version that outputs the missing characters if the string is not a pangram:
<syntaxhighlight lang="mathematica">pangramQ[msg_] :=
<syntaxhighlight lang="mathematica">pangramQ[msg_] :=
Function[If[# === {}, Print["The string is a pangram!"],
Function[If[# === {}, Print["The string is a pangram!"],
Print["The string is not a pangram. It's missing the letters " <>
Print["The string is not a pangram. It's missing the letters " <>
ToString[#]]]][
ToString[#]]]][
Complement[CharacterRange["a", "z"], Characters[ToLowerCase[msg]]]]</syntaxhighlight>
Complement[CharacterRange["a", "z"], Characters[ToLowerCase[msg]]]]</syntaxhighlight>
Line 2,278: Line 2,358:


=={{header|MATLAB}} / {{header|Octave}}==
=={{header|MATLAB}} / {{header|Octave}}==

<syntaxhighlight lang="matlab">function trueFalse = isPangram(string)
<syntaxhighlight lang="matlab">function trueFalse = isPangram(string)
% X is a histogram of letters
% X is a histogram of letters
Line 2,301: Line 2,381:
"Peter Piper picked a peck of pickled peppers.",
"Peter Piper picked a peck of pickled peppers.",
"Waltz job vexed quick frog nymphs."]
"Waltz job vexed quick frog nymphs."]

alphabet = "abcdefghijklmnopqrstuvwxyz"
alphabet = "abcdefghijklmnopqrstuvwxyz"

pangram = function (toCheck)
pangram = function (toCheck)
sentence = toCheck.lower
sentence = toCheck.lower
Line 2,312: Line 2,392:
return true
return true
end function
end function

for sentence in sentences
for sentence in sentences
if pangram(sentence) then
if pangram(sentence) then
print """" + sentence + """ is a Pangram"
print """" + sentence + """ is a Pangram"
else
else
print """" + sentence + """ is not a Pangram"
print """" + sentence + """ is not a Pangram"
end if
end if
Line 2,331: Line 2,411:
<syntaxhighlight lang="ocaml">fun to_locase s = implode ` map (c_downcase) ` explode s
<syntaxhighlight lang="ocaml">fun to_locase s = implode ` map (c_downcase) ` explode s


fun is_pangram
fun is_pangram
(h :: t, T) =
(h :: t, T) =
let
let
val flen = len (filter (fn c = c eql h) T)
val flen = len (filter (fn c = c eql h) T)
in
in
Line 2,341: Line 2,421:
is_pangram (t, T)
is_pangram (t, T)
end
end
| ([], T) = true
| ([], T) = true
| S = is_pangram (explode "abcdefghijklmnopqrstuvwxyz", explode ` to_locase S)
| S = is_pangram (explode "abcdefghijklmnopqrstuvwxyz", explode ` to_locase S)

fun is_pangram_i
fun is_pangram_i
(h :: t, T) =
(h :: t, T) =
let
let
val flen = len (filter (fn c = c eql h) T)
val flen = len (filter (fn c = c eql h) T)
in
in
Line 2,354: Line 2,434:
is_pangram (t, T)
is_pangram (t, T)
end
end
| ([], T) = true
| ([], T) = true
| (A,S) = is_pangram (explode A, explode ` to_locase S)
| (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 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)
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, "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");
println ` test (is_pangram, "abcdefghijklopqrstuvwxyz", true, "is a pangram", "is not a pangram");
val SValphabet = "abcdefghijklmnopqrstuvwxyzåäö";
val SValphabet = "abcdefghijklmnopqrstuvwxyzåäö";
val SVsentence = "Yxskaftbud, ge vår wczonmö iq hjälp";
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");
println ` test2 (is_pangram_i, (SValphabet, SVsentence), true, "is a Swedish pangram", "is not a Swedish pangram");
</syntaxhighlight>
</syntaxhighlight>
{{out}}
{{out}}
Line 2,623: Line 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;">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: #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: #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>
<span style="color: #008000;">"The quick brown fox jumps over the lazy dog"</span><span style="color: #0000FF;">,</span>
Line 2,742: Line 2,822:
<syntaxhighlight lang="picat">go =>
<syntaxhighlight lang="picat">go =>
S1 = "The quick brown fox jumps over the lazy dog",
S1 = "The quick brown fox jumps over the lazy dog",
S2 = "The slow brown fox jumps over the lazy dog",
S2 = "The slow brown fox jumps over the lazy dog",
println([S1, is_pangram(S1)]),
println([S1, is_pangram(S1)]),
println([S2, is_pangram(S2)]),
println([S2, is_pangram(S2)]),
Line 2,811: Line 2,891:
{{out}}
{{out}}
<pre>
<pre>
Please type a sentence
Please type a sentence


the quick brown fox jumps over the lazy dog
the quick brown fox jumps over the lazy dog
The sentence is a pangram.
The sentence is a pangram.
</pre>
</pre>


Line 2,825: Line 2,905:
$Text = $Text.ToLower()
$Text = $Text.ToLower()
$Alphabet = $Alphabet.ToLower()
$Alphabet = $Alphabet.ToLower()

$IsPangram = @( $Alphabet.ToCharArray() | Where-Object { $Text.Contains( $_ ) } ).Count -eq $Alphabet.Length
$IsPangram = @( $Alphabet.ToCharArray() | Where-Object { $Text.Contains( $_ ) } ).Count -eq $Alphabet.Length

return $IsPangram
return $IsPangram
}
}

Test-Pangram 'The quick brown fox jumped over the lazy dog.'
Test-Pangram 'The quick brown fox jumped over the lazy dog.'
Test-Pangram 'The quick brown fox jumps over the lazy dog.'
Test-Pangram 'The quick brown fox jumps over the lazy dog.'
Line 2,872: Line 2,952:
{{out}}
{{out}}
<pre>?- pangram_example.
<pre>?- pangram_example.
the quick brown fox jumps over the lazy dog --> ok
the quick brown fox jumps over the lazy dog --> ok
the quick brown fox jumped over the lazy dog --> ko
the quick brown fox jumped over the lazy dog --> ko
true.</pre>
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}}==
=={{header|Python}}==
Line 2,947: Line 2,994:
my.letters <- tolower(unlist(strsplit(sentence, "")))
my.letters <- tolower(unlist(strsplit(sentence, "")))
is.pangram <- all(letters %in% my.letters)
is.pangram <- all(letters %in% my.letters)

if (is.pangram){
if (is.pangram){
cat("\"", sentence, "\" is a pangram! \n", sep="")
cat("\"", sentence, "\" is a pangram! \n", sep="")
Line 3,035: Line 3,082:


──────── Please enter a pangramic sentence (or a blank to quit):
──────── Please enter a pangramic sentence (or a blank to quit):
◄■■■■■■■■■■ user input (null or some blanks).
◄■■■■■■■■■■ user input (null or some blanks).


──────── PANGRAM program ended. ────────
──────── PANGRAM program ended. ────────
Line 3,045: Line 3,092:
s = "The quick brown fox jumps over the lazy dog."
s = "The quick brown fox jumps over the lazy dog."
see "" + pangram(s) + " " + s + nl
see "" + pangram(s) + " " + s + nl

s = "My dog has fleas."
s = "My dog has fleas."
see "" + pangram(s) + " " + s + nl
see "" + pangram(s) + " " + s + nl

func pangram str
func pangram str
str = lower(str)
str = lower(str)
Line 3,054: Line 3,101:
bool = substr(str, char(i)) > 0
bool = substr(str, char(i)) > 0
pangram = pangram + bool
pangram = pangram + bool
next
next
pan = (pangram = 26)
pan = (pangram = 26)
return pan
return pan
Line 3,067: Line 3,114:
p pangram?('this is a sentence') # ==> false
p pangram?('this is a sentence') # ==> false
p pangram?('The quick brown fox jumps over the lazy dog.') # ==> true</syntaxhighlight>
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}}==
=={{header|Rust}}==
Line 3,250: Line 3,281:


define('panchk(str)tf') :(panchk_end)
define('panchk(str)tf') :(panchk_end)
panchk output = str
panchk output = str
tf = 'False'; tf = pangram(str) 'True'
tf = 'False'; tf = pangram(str) 'True'
output = 'Pangram: ' tf :(return)
output = 'Pangram: ' tf :(return)
Line 3,377: Line 3,408:
#cast %bL
#cast %bL


test =
test =


is_pangram* <
is_pangram* <
Line 3,398: Line 3,429:
Dim sLow As String
Dim sLow As String
Dim i As Integer
Dim i As Integer

sLow = LCase(s)
sLow = LCase(s)
For i = 1 To 26
For i = 1 To 26
Line 3,439: Line 3,470:
pangram = ( ltrim(sKey) = vbnullstring )
pangram = ( ltrim(sKey) = vbnullstring )
end function
end function

function eef( bCond, exp1, exp2 )
function eef( bCond, exp1, exp2 )
if bCond then
if bCond then
Line 3,563: Line 3,594:
no
no
</pre>
</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}}==
=={{header|zkl}}==