Pangram checker: Difference between revisions

Added uBasic/4tH version
m (syntax highlighting fixup automation)
imported>Thebeez
(Added uBasic/4tH version)
 
(17 intermediate revisions by 12 users not shown)
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 258:
=={{header|APL}}==
<syntaxhighlight lang="apl">
a←'abcdefghijklmnopqrstuvwxyz' ⍝ or ⎕ucs 96 + ⍳26 in GNU/Dyalog
A←'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ⍝ or ⎕ucs 64 + ⍳26, or just ⎕a in Dyalog
 
Panagram←Pangram ← {∧/ ∨⌿ 2 26⍴(a,A) ∊ ⍵}
PanagramPangram 'This should fail'
0
PanagramPangram 'The quick brown fox jumps over the lazy dog'
1
</syntaxhighlight>
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}}==
==={{header|Applesoft BASIC}}===
{{works with|QBasic}}
<syntaxhighlight lang="gwbasic"> 100 P$ = "11111111111111111111111111"
110 FOR Q = 1 TO 3
120 READ S$
130 GOSUB 200"IS PANGRAM?
140 PRINT MID$ ("NO YES ",P * 4 + 1,4)S$
150 NEXT Q
160 END
170 DATA"THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG."
180 DATA"THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG."
190 DATA"THE FIVE BOXING WIZARDS JUMP QUICKLY."
200 P = 0:L = LEN (S$): IF NOT L THEN RETURN
210 F$ = "00000000000000000000000000"
220 FOR I = 1 TO L
230 C = ASC ( MID$ (S$,I,1)):C = C - 32 * (C > 95): IF C > 64 AND C < 91 THEN J = C - 64:F$ = MID$ (F$,1,J - 1) + "1" + MID$ (F$,J + 1):P = F$ = P$: IF P THEN RETURN
240 NEXT I
250 RETURN</syntaxhighlight>
{{out}}
<pre>
YES THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
NO THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG.
YES THE FIVE BOXING WIZARDS JUMP QUICKLY.
</pre>
==={{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|Commodore BASIC}}===
<syntaxhighlight lang="gwbasic">10 rem detect model for title display
20 mx=peek(213): if mx=21 or mx=39 or mx=79 then 50:rem pet, vic, c64
30 mx=peek(238): if mx=39 or mx=79 then 50: rem c128
40 mx=39:color 4,1:rem assume plus/4 or c-16
50 if mx=21 then poke 36879,30:rem fix color on vic-20
60 print chr$(147);chr$(14);chr$(18);"**";:for i=2 to (mx-15)/2:print " ";:next
70 print "Pangram Checker";
80 for i=(mx-15)/2+16 to mx-2: print " ";: next: print "**"
100 read s$
110 if len(s$)=0 then end
120 gosub 1000:print
130 print "'"s$"' is";
140 if p=0 then print " not";
150 print " a pangram."
160 goto 100
500 data "The quick brown fox jumps over the lazy dog."
510 data "The quick brown fox jumped over the lazy dog."
520 data "The five boxing wizards jump quickly."
530 data
900 rem pangram checker
1000 if f=0 then f=1:dim seen(25),a(2):a(0)=65:a(1)=97:a(2)=193:goto 1020
1010 for i=0 to 25:seen(i)=0:next
1020 for i=1 to len(s$)
1030 : c=asc(mid$(s$,i))
1040 : for a = 0 to 2
1050 : if c>=a(a) and c<=a(a)+25 then seen(c-a(a))=seen(c-a(a))+1
1060 : next a
1070 next i
1080 p=-1
1090 for i=0 to 25
1100 : if seen(i)=0 then p=0:i=25
1110 next i
1120 return</syntaxhighlight>
 
{{Out}}
<pre>** Pangram Checker **
 
 
'The quick brown fox jumps over the lazy dog.' is a pangram.
 
'The quick brown fox jumped over the lazy dog.' is not a pangram.
 
'The five boxing wizards jump quickly.' is a pangram.
 
ready.</pre>
 
==={{header|Chipmunk Basic}}===
The [[#Applesoft BASIC|Applesoft BASIC]] solution works without any changes.
 
==={{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 ⟶ 867:
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 ⟶ 913:
<pre>NOT A PANGRAM</pre>
 
==={{header|BaConuBasic/4tH}}===
<syntaxhighlight lang="basic">Proc _ShowPangram ("The quick brown fox jumps over the lazy dog.")
This can be done in a one-liner.
Proc _ShowPangram ("QwErTyUiOpAsDfGhJkLzXcVbNm")
<syntaxhighlight lang="bacon">DEF FN Pangram(x) = IIF(AMOUNT(UNIQ$(EXPLODE$(EXTRACT$(LCASE$(x), "[^[:alpha:]]", TRUE), 1))) = 26, TRUE, FALSE)
Proc _ShowPangram ("Not a pangram")
 
End
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>
 
_ShowPangram ' demonstrate the Pangram() function
Param (1)
Print Show (a@);Tab (50);Show (Iif (FUNC(_Pangram (a@)), "A pangram", "Not a pangram"))
Return
 
_Pangram
=={{header|BASIC256}}==
Param (1) ' pangram candidate
<syntaxhighlight lang="freebasic">function isPangram$(texto$)
Local (3)
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
 
b@ = 0 ' reset the bitmap
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>
 
For d@ = 0 To Len(a@) -1 ' parse the string
c@ = Peek (a@, d@) ' get current character
If (c@ > Ord ("A") - 1) * (c@ < Ord ("Z") + 1) Then c@ = c@ + 32
If (c@ > Ord ("a") - 1) * (c@ < Ord ("z") + 1) Then b@ = OR(b@, 2^(c@ - Ord ("a")))
Next ' update the bitmap
Return (b@ = 67108863) ' all bits set?</syntaxhighlight>
{{Out}}
<pre>The quick brown fox jumps over the lazy dog. A pangram
QwErTyUiOpAsDfGhJkLzXcVbNm A pangram
Not a pangram Not a pangram
 
0 OK, 0:156</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|Batch File}}==
Line 727 ⟶ 1,010:
 
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 ⟶ 1,069:
)
& !k:>z
&
);</syntaxhighlight>
Some examples:
Line 1,039 ⟶ 1,273:
=={{header|Ceylon}}==
<syntaxhighlight lang="ceylon">shared void run() {
 
function pangram(String sentence) =>
let(alphabet = set('a'..'z'),
Line 1,065 ⟶ 1,299:
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,319:
"abcdefghijklmnopqrstuvwxyz"
]
 
for example: string in array[string]$elements(examples) do
stream$puts(po, "\"" || example || "\" is")
Line 1,163 ⟶ 1,397:
for i in [a_code...a_code+26]
required_letters[String.fromCharCode(i)] = true
 
cnt = 0
for c in s
Line 1,224 ⟶ 1,458:
 
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,519:
var letters: uint8[26];
MemZero(&letters[0], 26);
 
loop
var chr := [str];
Line 1,294 ⟶ 1,528:
letters[chr] := letters[chr] | 1;
end loop;
 
r := 1;
chr := 0;
Line 1,329 ⟶ 1,563:
('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,648:
byte A = pretend('a', byte);
byte Z = pretend('z', byte);
 
letters := 0L0;
while
Line 1,430 ⟶ 1,664:
 
proc nonrec test(*char s) void:
writeln("\"", s, "\": ",
if pangram(s) then "yes" else "no" fi)
corp
Line 1,451 ⟶ 1,685:
 
<code>&amp;!</code> is the “but-not” or set difference operator.
 
=={{header|EasyLang}}==
<syntaxhighlight lang="easylang">
func pangr s$ .
len d[] 26
for c$ in strchars s$
c = strcode c$
if c >= 97 and c <= 122
c -= 32
.
if c >= 65 and c <= 91
d[c - 64] = 1
.
.
for h in d[]
s += h
.
return s
.
repeat
s$ = input
until s$ = ""
print s$
if pangr s$ = 26
print " --> pangram"
.
print ""
.
input_data
This is a test.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumped over the lazy dog.
QwErTyUiOpAsDfGhJkLzXcVbNm
</syntaxhighlight>
 
=={{header|EDSAC order code}}==
Line 1,653 ⟶ 1,921:
)</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 ⟶ 2,046:
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,834 ⟶ 2,064:
"The quick brown fox jumps over the lazy dog." is a pangram.
</pre>
 
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
include "NSLog.incl"
 
local fn IsPangram( pangramString as CFStringRef ) as BOOL
NSUInteger i, count
BOOL result
CFStringRef lcPanStr = fn StringLowerCaseString( pangramString )
CFMutableSetRef mutSet = fn MutableSetWithCapacity( 0 )
count = len(lcPanStr)
for i = 0 to count - 1
if ( fn CharacterSetCharacterIsMember( fn CharacterSetLowercaseLetterSet, fn StringCharacterAtIndex( lcPanStr, i ) ) )
MutableSetAddObject( mutSet, fn StringWithFormat( @"%c", fn StringCharacterAtIndex( lcPanStr, i ) ) )
end if
next
if fn SetCount( mutSet ) >= 26 then result = YES else result = NO
end fn = result
 
 
CFStringRef testStr, trueStr, falseStr
CFArrayRef array
 
trueStr = @"Is a pangram"
falseStr = @"Not a pangram"
 
array = @[¬
@"My dog has fleas.",¬
@"The quick brown fox jumps over the lazy do.",¬
@"The quick brown fox jumped over the lazy dog.",¬
@"The quick brown fox jumps over the lazy dog.",¬
@"Jackdaws love my big sphinx of quartz.",¬
@"What's a jackdaw?",¬
@"Watch \"Jeopardy!\", Alex Trebek's fun TV quiz game.",¬
@"Pack my box with five dozen liquor jugs.",¬
@"This definitely is not a pangram.",¬
@"This is a random long sentence just for testing purposes."]
 
for testStr in array
if ( fn IsPangram( testStr ) )
NSLog( @"%13s : %@", fn StringUTF8String( trueStr ), testStr ) else NSLog( @"%s : %@", fn StringUTF8String( falseStr ), testStr )
end if
next
 
HandleEvents
</syntaxhighlight>
{{output}}
<pre>
Not a pangram : My dog has fleas.
Not a pangram : The quick brown fox jumps over the lazy do.
Not a pangram : The quick brown fox jumped over the lazy dog.
Is a pangram : The quick brown fox jumps over the lazy dog.
Is a pangram : Jackdaws love my big sphinx of quartz.
Not a pangram : What's a jackdaw?
Is a pangram : Watch "Jeopardy!", Alex Trebek's fun TV quiz game.
Is a pangram : Pack my box with five dozen liquor jugs.
Not a pangram : This definitely is not a pangram.
Not a pangram : This is a random long sentence just for testing purposes.
</pre>
 
 
 
 
=={{header|Fōrmulæ}}==
 
{{FormulaeEntry|page=https://formulae.org/?script=examples/Pangram_checker}}
Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text. Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for storage and transfer purposes more than visualization and edition.
 
'''Solution'''
 
[[File:Fōrmulæ - Pangram checker 01.png]]
 
'''Test cases'''
 
[[File:Fōrmulæ - Pangram checker 02.png]]
 
[[File:Fōrmulæ - Pangram checker 03.png]]
 
[[File:Fōrmulæ - Pangram checker 04.png]]
Programs in Fōrmulæ are created/edited online in its [https://formulae.org website], However they run on execution servers. By default remote servers are used, but they are limited in memory and processing power, since they are intended for demonstration and casual use. A local server can be downloaded and installed, it has no limitations (it runs in your own computer). Because of that, example programs can be fully visualized and edited, but some of them will not run if they require a moderate or heavy computation/memory resources, and no local server is being used.
 
[[File:Fōrmulæ - Pangram checker 05.png]]
In '''[https://formulae.org/?example=Pangram_checker this]''' page you can see the program(s) related to this task and their results.
 
=={{header|Go}}==
Line 1,909 ⟶ 2,214:
 
=={{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,223:
 
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>
 
=={{Header|Insitux}}==
 
<syntaxhighlight lang="insitux">
(function pangram? sentence
(let prepped (-> sentence lower-case to-vec))
(all? prepped (map char-code (range 97 123))))
 
(pangram? "The five boxing wizards jump quickly.")
</syntaxhighlight>
 
=={{header|Io}}==
Line 2,091 ⟶ 2,406:
 
=={{header|K}}==
{{works with|Kona}}
<syntaxhighlight lang="k">lcase : _ci 97+!26
ucase : _ci 65+!26
Line 2,101 ⟶ 2,417:
panagram "Panagram test"
0</syntaxhighlight>
 
{{works with|ngn/k}}
<syntaxhighlight lang=K>isPangram:0=#(`c$"a"+!26)^_:
 
isPangram"This is a test"
0
isPangram"The quick brown fox jumps over the lazy dog."
1</syntaxhighlight>
 
=={{header|Kotlin}}==
Line 2,111 ⟶ 2,435:
if (c !in t) return false
return true
}
 
fun main(args: Array<String>) {
Line 2,120 ⟶ 2,444:
"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,504:
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,555:
 
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,588:
 
=={{header|MATLAB}} / {{header|Octave}}==
 
<syntaxhighlight lang="matlab">function trueFalse = isPangram(string)
% X is a histogram of letters
Line 2,301 ⟶ 2,611:
"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,622:
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,641:
<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,651:
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,664:
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,933:
<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,653 ⟶ 2,963:
no - no a
</pre>
 
=={{header|Phixmonti}}==
<syntaxhighlight lang="Phixmonti">include ..\Utilitys.pmt
 
def pangram?
lower "abcdefghijklmnopqrstuvwxyz" swap remove len not nip
enddef
 
"The quick brown fox jumps over the lazy dog." pangram?
"This is a test" pangram?
"NOPQRSTUVWXYZ abcdefghijklm" pangram?
"abcdefghijklopqrstuvwxyz" pangram?
 
pstack</syntaxhighlight>
{{out}}
<pre>
[1, 0, 1, 0]
 
=== Press any key to exit ===</pre>
 
=={{header|PHP}}==
Line 2,742 ⟶ 3,071:
<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 ⟶ 3,140:
{{out}}
<pre>
Please type a sentence
 
the quick brown fox jumps over the lazy dog
The sentence is a pangram.
</pre>
 
Line 2,825 ⟶ 3,154:
$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 ⟶ 3,201:
{{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 ⟶ 3,243:
my.letters <- tolower(unlist(strsplit(sentence, "")))
is.pangram <- all(letters %in% my.letters)
 
if (is.pangram){
cat("\"", sentence, "\" is a pangram! \n", sep="")
Line 2,978 ⟶ 3,274:
(formerly Perl 6)
<syntaxhighlight lang="raku" line>constant Eng = set 'a' .. 'z';
constant Cyr = (set 'а' .. 'ё') (-) (set 'ъ', 'ѐ');
constant Hex = set 'a' .. 'f';
 
sub pangram($str, Set $alpha = Eng) {
$alpha ⊆ $str.lc.comb;
}
 
Line 3,035 ⟶ 3,331:
 
──────── Please enter a pangramic sentence (or a blank to quit):
◄■■■■■■■■■■ user input (null or some blanks).
 
──────── PANGRAM program ended. ────────
Line 3,045 ⟶ 3,341:
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,350:
bool = substr(str, char(i)) > 0
pangram = pangram + bool
next
pan = (pangram = 26)
return pan
</syntaxhighlight>
 
=={{header|RPL}}==
====Structurally programmed====
{| class="wikitable" ≪
! RPL code
! Comment
|-
|
# 0h SWAP 1 OVER SIZE '''FOR''' j
DUP j DUP SUB NUM
'''IF''' DUP 97 ≥ OVER 122 ≤ AND '''THEN''' 32 - '''END'''
'''IF''' DUP 65 ≥ OVER 90 ≤ AND '''THEN'''
2 SWAP 65 - ^ R→B ROT OR SWAP
'''ELSE''' DROP '''END'''
'''NEXT''' DROP # 3FFFFFFh ==
≫ ‘<span style="color:blue">PANG?</span>’ STO
|
<span style="color:blue">PANG?</span> ''( "sentence" → boolean ) ''
alpha = 0; loop for j = 1 to length(sentence)
c = ascii(sentence[j])
if c lowercase then make it uppercase
if c in ("A".."Z") then
alpha &= 2^(c-65)
end loop
return alpha & 3FFFFFFh
|}
====Idiomatically optimized for HP-28S====
{| class="wikitable" ≪
! RPL code
! Comment
|-
|
# 7FFFFFEh RCLF OVER NOT AND STOF SWAP
1 OVER SIZE '''FOR''' j
DUP j DUP SUB NUM
DUP 97 ≥ 95 63 IFTE - 1 MAX 28 MIN SF
'''NEXT''' DROP RCLF OVER AND ==
≫ ‘<span style="color:blue">PANG?</span>’ STO
|
<span style="color:blue">PANG?</span> ''( "sentence" → boolean ) ''
clear flags 1 to 28
loop for j = 1 to length(sentence)
c = ascii(sentence[j])
reduce c to a value between 1 and 28 and set related flag
return 1 if all flags between 2 and 27 are set
|}
To run on more recent models, the following sequence in line 2
RCLF OVER NOT AND STOF
must be replaced by
RCLF DUP 2 GET 3 PICK NOT AND 2 SWAP PUT STOF
and <code>RCLF</code> in the last line by <code>RCLF 2 GET</code>.
"The quick brown fox jumps over the lazy dog" <span style="color:blue">PANG?</span>
"The quick brown fox jumped over the lazy dog" <span style="color:blue">PANG?</span>
{{out}}
<pre>
2: 1
1: 0
</pre>
 
=={{header|Ruby}}==
Line 3,067 ⟶ 3,425:
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,592:
 
define('panchk(str)tf') :(panchk_end)
panchk output = str
tf = 'False'; tf = pangram(str) 'True'
output = 'Pangram: ' tf :(return)
Line 3,354 ⟶ 3,696:
=={{header|UNIX Shell}}==
{{works with|Bourne Again SHell}}
{{works with|Korn Shell}}
<syntaxhighlight lang="bash">function pangram? {
{{works with|Z Shell}}
local alphabet=abcdefghijklmnopqrstuvwxyz
<syntaxhighlight lang="bash">function is_pangram {
local string="$*"
typeset alphabet=abcdefghijklmnopqrstuvwxyz
string="${string,,}"
while [[typeset -nl "$string" && -n "=$alphabet" ]]; do*
while [[ local-n ch="${string%% && -n ${string#?}}"alphabet ]]; do
stringtypeset ch="${string%%${string#?}"}
alphabetstring="${alphabet/$chstring#?}"
alphabet=${alphabet/$ch}
done
[[ -z "$alphabet" ]]
}</syntaxhighlight>
 
Line 3,376 ⟶ 3,719:
#cast %bL
 
test =
 
is_pangram* <
Line 3,397 ⟶ 3,740:
Dim sLow As String
Dim i As Integer
 
sLow = LCase(s)
For i = 1 To 26
Line 3,438 ⟶ 3,781:
pangram = ( ltrim(sKey) = vbnullstring )
end function
 
function eef( bCond, exp1, exp2 )
if bCond then
Line 3,486 ⟶ 3,829:
=={{header|Wren}}==
{{libheader|Wren-str}}
<syntaxhighlight lang="ecmascriptwren">import "./str" for Str
 
var isPangram = Fn.new { |s|
Line 3,562 ⟶ 3,905:
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}}==
Anonymous user