Pangram checker: Difference between revisions
Content deleted Content added
Not a robot (talk | contribs) Add Cowgol |
imported>Thebeez Added uBasic/4tH version |
||
(52 intermediate revisions by 26 users not shown) | |||
Line 1:
[[Category:String manipulation]]
{{task}}
{{omit from|Lilypond}}
Line 17:
:* [https://rosettacode.org/wiki/Determine_if_a_string_has_all_unique_characters determine if a string has all unique characters]
<br><br>
=={{header|11l}}==
<syntaxhighlight lang="11l">F is_pangram(sentence)
R Set(sentence.lowercase().filter(ch -> ch C ‘a’..‘z’)).len == 26
L(sentence) [‘The quick brown fox jumps over the lazy dog.’,
‘The quick brown fox jumped over the lazy dog.’]
print(‘'#.' is #.a pangram’.format(sentence, ‘not ’ * !is_pangram(sentence)))</syntaxhighlight>
{{out}}
<pre>
'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
</pre>
=={{header|360 Assembly}}==
<
PANGRAM CSECT
USING PANGRAM,R12
Line 35 ⟶ 49:
LA R5,1 found
NEXTK LA R11,1(R11) next character
BCT R8,LOOPK
LTR R5,R5 if found
BNZ NEXTJ
Line 41 ⟶ 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 55 ⟶ 69:
DC CL60'PACK MY BOX WITH FIVE DOZEN LIQUOR JUGS.'
BUFFER DC CL80' '
YREGS
END PANGRAM</
{{out}}
<pre>OK THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
Line 64 ⟶ 78:
=={{header|ACL2}}==
<
(if (endp needles)
t
Line 72 ⟶ 86:
(defun pangramp (str)
(contains-each (coerce "abcdefghijklmnopqrstuvwxyz" 'list)
(coerce (string-downcase str) 'list)))</
=={{header|Action!}}==
{{libheader|Action! Tool Kit}}
<syntaxhighlight lang="action!">INCLUDE "D2:CHARTEST.ACT" ;from the Action! Tool Kit
DEFINE CHAR_COUNT="26"
BYTE FUNC IsPangram(CHAR ARRAY t)
BYTE ARRAY tab(CHAR_COUNT)
BYTE i,c
FOR i=0 TO CHAR_COUNT-1
DO tab(i)=0 OD
FOR i=1 TO t(0)
DO
c=ToLower(t(i))
IF c>='a AND c<='z THEN
tab(c-'a)=1
FI
OD
FOR i=0 TO CHAR_COUNT-1
DO
IF tab(i)=0 THEN
RETURN (0)
FI
OD
RETURN (1)
PROC Test(CHAR ARRAY t)
BYTE res
res=IsPangram(t)
PrintF("""%S"" is ",t)
IF res=0 THEN
Print("not ")
FI
PrintE("a pangram.")
PutE()
RETURN
PROC Main()
Put(125) PutE() ;clear screen
Test("The quick brown fox jumps over the lazy dog.")
Test("QwErTyUiOpAsDfGhJkLzXcVbNm")
Test("Not a pangram")
Test("")
RETURN</syntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Pangram_checker.png Screenshot from Atari 8-bit computer]
<pre>
"The quick brown fox jumps over the lazy dog." is a pangram.
"QwErTyUiOpAsDfGhJkLzXcVbNm" is a pangram.
"Not a pangram" is not a pangram.
"" is not a pangram.
</pre>
=={{header|ActionScript}}==
{{works with|ActionScript|2.0}}
<
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;
}</
=={{header|Ada}}==
=== Using character sets ===
<
with Ada.Strings.Maps; use Ada.Strings.Maps;
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 109 ⟶ 183:
put_line(Boolean'Image(ispangram("abcdefghijklopqrstuvwxyz"))); --Missing m, n
end pangram;
</syntaxhighlight>
=== Using quantified expressions ===
<
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 125 ⟶ 199:
put_line(Boolean'Image(ispangram("abcdefghijklopqrstuvwxyz"))); --Missing m, n
end pangram;
</syntaxhighlight>
{{out}}
<pre>
Line 140 ⟶ 214:
{{works with|ELLA ALGOL 68|Any (with appropriate job cards)}}
<
INT la = ABS "a", lz = ABS "z";
INT ua = ABS "A", uz = ABS "Z";
Line 175 ⟶ 249:
FI
OD
)</
{{out}}
<pre>
Line 183 ⟶ 257:
=={{header|APL}}==
<
a←'abcdefghijklmnopqrstuvwxyz' ⍝ or ⎕ucs 96 + ⍳26 in GNU/Dyalog
A←'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ⍝ or ⎕ucs 64 + ⍳26, or just ⎕a in Dyalog
0
1
</syntaxhighlight>
=={{header|AppleScript}}==
===AppleScriptObjC===
Out of the box, AppleScript lacks many library basics – no regex, no higher order functions, not even string functions for mapping to upper or lower case.
From OSX 10.10 onwards, we can, however, use ObjC functions from AppleScript by importing the Foundation framework. We do this below to get a toLowerCase() function. If we also add generic filter and map functions, we can write and test a simple isPangram() function as follows:
<
-- isPangram :: String -> Bool
Line 212 ⟶ 286:
end |λ|
end script
0 = length of filter(charUnUsed,
"abcdefghijklmnopqrstuvwxyz")
end isPangram
on run
map(isPangram, {¬
"is this a pangram", ¬
"The quick brown fox jumps over the lazy dog"})
--> {false, true}
end run
-------------------- GENERIC FUNCTIONS -------------------
-- filter :: (a -> Bool) -> [a] -> [a]
Line 240 ⟶ 316:
end tell
end filter
-- map :: (a -> b) -> [a] -> [b]
Line 253 ⟶ 330:
end map
-- Lift 2nd class handler function into
-- 1st class script wrapper
-- mReturn :: Handler -> Script
on mReturn(f)
Line 264 ⟶ 343:
end if
end mReturn
-- toLower :: String -> String
Line 270 ⟶ 350:
((ca's NSString's stringWithString:(str))'s ¬
lowercaseStringWithLocale:(ca's NSLocale's currentLocale())) as text
end toLower</
{{Out}}
<syntaxhighlight lang
----
===Core language===
Contrary to the impression given above, AppleScript is perfectly capable of handling this task very simply and without the need for imported libraries.
<syntaxhighlight lang="applescript">on isPangram(txt)
set alphabet to "abcedfghijklmnopqrstuvwxyz"
ignoring case -- The default, but ensure it here.
repeat with letter in alphabet
if (txt does not contain letter) then return false
end repeat
end ignoring
return true
end isPangram
local result1, result2
set result1 to isPangram("The Quick Brown Fox Jumps Over The Lazy Dog")
set result2 to isPangram("This is not a pangram")
return {result1, result2}</syntaxhighlight>
{{output}}
<syntaxhighlight lang="applescript">{true, false}</syntaxhighlight>
=={{header|Arturo}}==
<syntaxhighlight lang="rebol">chars: map 97..122 => [to :string to :char &]
pangram?: function [sentence][
every? chars 'ch ->
in? ch sentence
]
print pangram? "this is a sentence"
print pangram? "The quick brown fox jumps over the lazy dog."</syntaxhighlight>
{{out}}
<pre>false
true</pre>
=={{header|ATS}}==
<syntaxhighlight lang="ats">
(* ****** ****** *)
//
Line 321 ⟶ 437:
(* ****** ****** *)
</syntaxhighlight>
An alternate implementation that makes a single pass through the string:
<
val letters: arrayref(bool, 26) = arrayref_make_elt<bool>(i2sz(26), false)
fn check(): bool = loop(0) where {
Line 344 ⟶ 460:
end
}
</syntaxhighlight>
=={{header|AutoHotkey}}==
<
Gui, Add, Edit, w300 r5 vText
Gui, Add, Button, x105 w100 Default, Check Pangram
Line 365 ⟶ 481:
}
MsgBox,, Pangram, OK`, this is a Pangram!
Return</
=={{header|AutoIt}}==
<
Pangram("The quick brown fox jumps over the lazy dog")
Func Pangram($s_String)
Line 378 ⟶ 494:
Return MsgBox(0,"Pangram", "Sentence is a Pangram")
EndFunc
</syntaxhighlight>
=={{header|AWK}}==
===Solution using string-operations===
<
BEGIN {
allChars="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
Line 397 ⟶ 513:
for (k=1; k<=length(allChars); k++) {
if (!X[substr(allChars,k,1)]) return 0;
}
return 1;
}</
{{out}}
Line 408 ⟶ 524:
{{Works with|gawk|4.1.0}}
{{Works with|mawk|1.3.3}}
<
#
# Pangram-checker, using associative arrays and split
Line 434 ⟶ 550:
}
print "# hit:",hit, "# miss:",miss, "." ##
if (miss) return 0
return 1
}</
{{out}}
Line 459 ⟶ 575:
=={{header|BASIC}}==
==={{header|Applesoft BASIC}}===
<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}}===
<
DIM x AS STRING
Line 502 ⟶ 859:
IsPangram! = -1
END FUNCTION</
{{out}}
<pre>
Line 510 ⟶ 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}}===
Works (just) with the 1k RAM model. The "37" that crops up a couple of times stops being a mystery if we remember that the ZX81 character code for <code>A</code> is 38 and that strings (like arrays) are indexed from 1, not from 0.
<
20 LET L=26
30 INPUT P$
Line 530 ⟶ 903:
160 GOTO 180
170 PRINT "NOT A PANGRAM"
180 SLOW</
{{in}}
<pre>THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.</pre>
Line 540 ⟶ 913:
<pre>NOT A PANGRAM</pre>
==={{header|
<syntaxhighlight lang="basic">Proc _ShowPangram ("The quick brown fox jumps over the lazy dog.")
Proc _ShowPangram ("QwErTyUiOpAsDfGhJkLzXcVbNm")
Proc _ShowPangram ("Not a pangram")
End
_ShowPangram ' demonstrate the Pangram() function
Param (1)
Print Show (a@);Tab (50);Show (Iif (FUNC(_Pangram (a@)), "A pangram", "Not a pangram"))
Return
_Pangram
Param (1) ' pangram candidate
Local (3)
b@ = 0 ' reset the bitmap
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}}==
<
setlocal enabledelayedexpansion
Line 587 ⟶ 1,004:
set letters=!letters:%chr%=!
set /a cnt+=1
goto loop</
{{Out}}
<pre>"The quick brown fox jumps over the lazy dog." is a pangram!
Line 594 ⟶ 1,011:
Press any key to continue . . .</pre>
=={{header|
<syntaxhighlight lang="bcpl">get "libhdr"
// Test if s is a pangram. The ASCII character set is assumed.
let pangram(s) = valof
$( let letters = vec 25
for i=0 to 25
for i=1 to s%0 do
$( let c
if c >= 0 & c < 26 then
for i=0 to 25 unless letters!i resultis false
resultis true
$)
// Display s and whether or not it is a pangram.
let check(s) be
$( writes(s)
writes(" -> ")
test
else writes("no*N")
$)
let start() be
$( check("The quick brown fox jumps over the lazy dog.")
check("The five boxing wizards dump quickly.")
$)</syntaxhighlight>
{{out}}
<pre>
=={{header|Befunge}}==
Line 632 ⟶ 1,048:
Reads the sentence to test from stdin.
<
^#*`\*93\`0<::-"@"-*<^40!%2g4:_
"pangram."<v*84<_v#-":"g40\" a"
>>:#,_55+,@>"ton">48*>"si tahT"</
{{in}}
Line 644 ⟶ 1,060:
=={{header|Bracmat}}==
<
k
. low$!arg:?arg
Line 653 ⟶ 1,069:
)
& !k:>z
&
);</
Some examples:
<pre>isPangram$("the Quick brown FOX jumps over the lazy do")
Line 672 ⟶ 1,088:
=={{header|Brat}}==
<
letters = [:a :b :c :d :e :f :g :h :i :j :k :l :m
:n :o :p :q :r :s :t :u :v :w :x :y :z]
Line 686 ⟶ 1,102:
p pangram? 'The quick brown fox jumps over the lazy dog.' #Prints true
p pangram? 'Probably not a pangram.' #Prints false</
Alternative version:
<
sentence.downcase.dice.unique.select(:alpha?).length == 26
}</
=={{header|C}}==
<
int is_pangram(const char *s)
Line 735 ⟶ 1,151:
tests[i], is_pangram(tests[i])?"":"not ");
return 0;
}</
===Using bitmask===
Assumes an execution environment using the ASCII character set (will invoke undefined behavior on other systems).
<
int pangram(const char *s)
Line 761 ⟶ 1,177:
return 0;
}</
{{out}}
<pre>yes: The quick brown fox jumps over lazy dogs.
Line 769 ⟶ 1,185:
C# 3.0 or higher (.NET Framework 3.5 or higher)
<
using System.Linq;
Line 783 ⟶ 1,199:
Console.WriteLine(arguments.Any() && arguments.First().IsPangram());
}
}</
Any version of C# language and .NET Framework
<
namespace PangrammChecker
Line 826 ⟶ 1,242:
}
}
}</
=={{header|C++}}==
<
#include <cctype>
#include <string>
Line 853 ⟶ 1,269:
}
}
</syntaxhighlight>
=={{header|Ceylon}}==
<
function pangram(String sentence) =>
let(alphabet = set('a'..'z'),
Line 872 ⟶ 1,288:
print("\"``sentence``\" is a pangram? ``pangram(sentence)``");
}
}</
=={{header|Clojure}}==
<
(let [letters (into #{} "abcdefghijklmnopqrstuvwxyz")]
(= (->> s .toLowerCase (filter letters) (into #{})) letters)))</
=={{header|CLU}}==
<syntaxhighlight lang="clu">pangram = proc (s: string) returns (bool)
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
if c>='A' & c<='Z' then
letters[char$c2i(c) - 65] := true
end
end
for seen: bool in array[bool]$elements(letters) do
if ~seen then return(false) end
end
return(true)
end pangram
start_up = proc ()
po: stream := stream$primary_output()
examples: array[string] := array[string]$[
"The quick brown fox jumps over the lazy dog.",
"The five boxing wizards dump quickly.",
"abcdefghijklmnopqrstuvwxyz"
]
for example: string in array[string]$elements(examples) do
stream$puts(po, "\"" || example || "\" is")
if ~pangram(example) then
stream$puts(po, " not")
end
stream$putl(po, " a pangram.")
end
end start_up</syntaxhighlight>
{{out}}
<pre>"The quick brown fox jumps over the lazy dog." is a pangram.
"The five boxing wizards dump quickly." is not a pangram.
"abcdefghijklmnopqrstuvwxyz" is a pangram.</pre>
=={{header|COBOL}}==
<
program-id. pan-test.
data division.
Line 930 ⟶ 1,384:
exit program
.
end program pangram.</
=={{header|CoffeeScript}}==
<
is_pangram = (s) ->
# This is optimized for longish strings--as soon as all 26 letters
Line 943 ⟶ 1,397:
for i in [a_code...a_code+26]
required_letters[String.fromCharCode(i)] = true
cnt = 0
for c in s
Line 968 ⟶ 1,422:
throw Error("fail") if is_pangram(long_str) != exp_value
console.log "Passed tests: #{s}"
</syntaxhighlight>
=={{header|Comal}}==
<syntaxhighlight lang="comal">0010 FUNC pangram#(s$) CLOSED
0020 FOR i#:=ORD("A") TO ORD("Z") DO
0030 IF NOT (CHR$(i#) IN s$ OR CHR$(i#+32) IN s$) THEN RETURN FALSE
0040 ENDFOR i#
0050 RETURN TRUE
0060 ENDFUNC
0070 //
0080 WHILE NOT EOD DO
0090 READ s$
0100 PRINT "'",s$,"' is ",
0110 IF NOT pangram#(s$) THEN PRINT "not ",
0120 PRINT "a pangram"
0130 ENDWHILE
0140 END
0150 DATA "The quick brown fox jumps over the lazy dog."
0160 DATA "The five boxing wizards dump quickly."</syntaxhighlight>
{{out}}
<pre>'The quick brown fox jumps over the lazy dog.' is a pangram
'The five boxing wizards dump quickly.' is not a pangram</pre>
=={{header|Common Lisp}}==
<
(null (set-difference
(loop for c from (char-code #\A) upto (char-code #\Z) collect (code-char c))
(coerce (string-upcase s) 'list))))</
=={{header|Component Pascal}}==
BlackBox Component Builder
<
MODULE BbtPangramChecker;
IMPORT StdLog,DevCommanders,TextMappers;
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,027 ⟶ 1,502:
END BbtPangramChecker.
</syntaxhighlight>
Execute: ^Q BbtPangramChecker.Do "The quick brown fox jumps over the lazy dog"~ <br/>
^Q BbtPangramChecker.Do "abcdefghijklmnopqrstuvwxyz"~<br/>
Line 1,039 ⟶ 1,514:
=={{header|Cowgol}}==
<
sub pangram(str: [uint8]): (r: uint8) is
var letters: uint8[26];
MemZero(&letters[0], 26);
loop
var chr := [str];
Line 1,053 ⟶ 1,528:
letters[chr] := letters[chr] | 1;
end loop;
r := 1;
chr := 0;
Line 1,074 ⟶ 1,549:
print(yesno[pangram(test[i])]);
i := i + 1;
end loop;</
{{out}}
Line 1,085 ⟶ 1,560:
Copied and modified from the Ruby version.
<
('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.")</
<pre>
Line 1,099 ⟶ 1,574:
=={{header|D}}==
===ASCII Bitmask version===
<
uint bitset;
Line 1,117 ⟶ 1,592:
assert(!"ABCDEFGHIJKL.NOPQRSTUVWXYZ".isPangram);
assert("ABC.D.E.FGHI*J/KL-M+NO*PQ R\nSTUVWXYZ".isPangram);
}</
===Unicode version===
<
// Do not compile with -g (debug info).
Line 1,141 ⟶ 1,616:
assert(isPangram("Falsches Üben von Xylophonmusik quält jeden größeren Zwerg"d, Alphabet.DE));
assert(isPangram("Yxskaftbud, ge vår wczonmö iqhjälp"w, Alphabet.SV));
}</
=={{header|Delphi}}==
<
{$APPTYPE CONSOLE}
Line 1,164 ⟶ 1,639:
Writeln(IsPangram('The quick brown fox jumps over the lazy dog')); // true
Writeln(IsPangram('Not a panagram')); // false
end.</
=={{header|Draco}}==
<syntaxhighlight lang="draco">proc nonrec pangram(*char s) bool:
ulong letters;
char c;
byte b;
byte A = pretend('a', byte);
byte Z = pretend('z', byte);
letters := 0L0;
while
c := s*;
s := s + 1;
c /= '\e'
do
b := pretend(c, byte) | 32;
if b >= A and b <= Z then
letters := letters | 0L1 << (b-A)
fi
od;
letters = 0x3FFFFFF
corp
proc nonrec test(*char s) void:
writeln("\"", s, "\": ",
if pangram(s) then "yes" else "no" fi)
corp
proc nonrec main() void:
test("The quick brown fox jumps over the lazy dog.");
test("The five boxing wizards jump quickly.");
test("Not a pangram")
corp</syntaxhighlight>
{{out}}
<pre>"The quick brown fox jumps over the lazy dog.": yes
"The five boxing wizards jump quickly.": yes
"Not a pangram": no</pre>
=={{header|E}}==
<
return ("abcdefghijklmnopqrstuvwxyz".asSet() &! sentence.toLowerCase().asSet()).size() == 0
}</
<code>&!</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,179 ⟶ 1,725:
it in a text file, making that file the active file, and clicking Reset.
The string must be terminated by a blank row of tape (represented by '.' in EdsacPC).
<
[Pangram checker for Rosetta Code.
EDSAC program, Initial Orders 2.]
Line 1,312 ⟶ 1,858:
P F [acc = 0 on entry]
THE!QUICK!BROWN!FOX!JUMPS!OVER!THE!LAZY!DOG.
</syntaxhighlight>
{{out}}
<pre>
Line 1,319 ⟶ 1,865:
=={{header|Elixir}}==
<
def checker(str) do
unused = Enum.to_list(?a..?z) -- to_char_list(String.downcase(str))
Line 1,329 ⟶ 1,875:
IO.puts "#{Pangram.checker(text)}\t#{text}"
text = (Enum.to_list(?A..?Z) -- 'Test') |> to_string
IO.puts "#{Pangram.checker(text)}\t#{text}"</
{{out}}
Line 1,338 ⟶ 1,884:
=={{header|Erlang}}==
<
-export([is_pangram/1]).
is_pangram(String) ->
ordsets:is_subset(lists:seq($a, $z), ordsets:from_list(string:to_lower(String))).</
=={{header|Excel}}==
===LAMBDA===
With the following lambda bound to the name ISPANGRAM in the Excel Workbook Name Manager:
(See [https://www.microsoft.com/en-us/research/blog/lambda-the-ultimatae-excel-worksheet-function/ LAMBDA: The ultimate Excel worksheet function])
{{works with|Office 265 Betas 2010}}
<syntaxhighlight lang="lisp">ISPANGRAM
=LAMBDA(s,
LET(
abc, CHARS(LOWER("abcdefghijklmnopqrstuvwxyz")),
AND(
LAMBDA(c,
ISNUMBER(SEARCH(c, s, 1))
)(
abc
)
)
)
)</syntaxhighlight>
And assuming that the name CHARS is also bound in the Name Manager
to the generic (String -> Array Char) lambda:
<syntaxhighlight lang="lisp">CHARS
=LAMBDA(s,
MID(s, ROW(INDIRECT("1:" & LEN(s))), 1)
)</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
|}
=={{header|F Sharp|F#}}==
If the difference between the set of letters in the alphabet and the set of letters in the given string (after conversion to lower case) is the empty set then every letter appears somewhere in the given string:
<
=={{header|Factor}}==
{{trans|E}}
<
[ "abcdefghijklmnopqrstuvwxyz" ] dip >lower diff length 0 = ;
"How razorback-jumping frogs can level six piqued gymnasts!" pangram? .</
=={{header|Forth}}==
<
0 -rot bounds do
i c@ 32 or [char] a -
Line 1,365 ⟶ 1,973:
1 26 lshift 1- = ;
s" The five boxing wizards jump quickly." pangram? . \ -1</
=={{header|Fortran}}==
{{works with|Fortran|90 and later}}
<
implicit none
Line 1,416 ⟶ 2,024:
end function is_pangram
end module pangram</
Example:
<
use pangram, only: is_pangram
Line 1,432 ⟶ 2,040:
write (*, '(l1)') is_pangram (string)
end program test</
{{out}}
<pre>This is a sentence.
Line 1,439 ⟶ 2,047:
T</pre>
=={{header|
<syntaxhighlight lang="frink">s = "The quick brown fox jumps over the lazy dog."
println["\"$s\" is" + (isPangram[s] ? "" : " not") + " a pangram."]
{
charSet = toSet[charList[lc[s]]]
if ! charSet.contains[c]
return true
}</syntaxhighlight>
{{out}}
<pre>
"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æ}}==
'''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]]
[[File:Fōrmulæ - Pangram checker 05.png]]
=={{header|Go}}==
<
import "fmt"
Line 1,522 ⟶ 2,185:
}
return false
}</
{{out}}
<pre>
Line 1,532 ⟶ 2,195:
=={{header|Haskell}}==
<
import Data.List ((\\))
Line 1,538 ⟶ 2,201:
pangram = null . (['a' .. 'z'] \\) . map toLower
main = print $ pangram "How razorback-jumping frogs can level six piqued gymnasts!"</
=={{header|HicEst}}==
<
PangramBrokenAt("The quick Brown Fox jumps over the Lazy Dog") ! => 0 (OK)
Line 1,548 ⟶ 2,211:
PangramBrokenAt = INDEX(Alfabet, string, 64)
! option 64: verify = 1st letter of string not in Alfabet
END</
=={{header|Icon}} and {{header|Unicon}}==
A panagram procedure:
<
if (map(s) ** &lcase) === &lcase then return s
end</
And a main to drive it:
<
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</
=={{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}}==
<
letters := " " repeated(26)
ia := "a" at(0)
Line 1,583 ⟶ 2,256:
"The quick brown fox jumps over the lazy dog." isPangram println // --> true
"The quick brown fox jumped over the lazy dog." isPangram println // --> false
"ABC.D.E.FGHI*J/KL-M+NO*PQ R\nSTUVWXYZ" isPangram println // --> true</
=={{header|Ioke}}==
<
letters = "abcdefghijklmnopqrstuvwxyz" chars
text = self lower chars
letters map(x, text include?(x)) reduce(&&)
)</
Here is an example of it's use in the Ioke REPL:
<
iik> "The quick brown fox jumps over the lazy dog" isPangram?
"The quick brown fox jumps over the lazy dog" isPangram?
Line 1,601 ⟶ 2,274:
iik> "The quick brown fox jumps over the" isPangram?
"The quick brown fox jumps over the" isPangram?
+> false</
=={{header|J}}==
'''Solution:'''
<
isPangram=: (a. {~ 97+i.26) */@e. tolower</
'''Example use:'''
<
1
isPangram 'The quick brown fox falls over the lazy dog.'
0</
=={{header|Java}}==
{{works with|Java|1.5+}}
<
public static boolean isPangram(String test){
for (char a = 'A'; a <= 'Z'; a++)
Line 1,633 ⟶ 2,306:
System.out.println(isPangram(""));//false
}
}</
{{out}}
<pre>true
Line 1,647 ⟶ 2,320:
====Iterative====
<
var letters = "zqxjkvbpygfwmucldrhsnioate"
// sorted by frequency ascending (http://en.wikipedia.org/wiki/Letter_frequency)
Line 1,657 ⟶ 2,330:
console.log(isPangram("is this a pangram")) // false
console.log(isPangram("The quick brown fox jumps over the lazy dog")) // true</
===ES6===
====Functional====
<
// ----------------- PANGRAM CHECKER -----------------
// isPangram :: String -> Bool
.split("")
.filter(c => -1 === s.toLowerCase().indexOf(c))
.length;
// ---------------------- TEST -----------------------
return [
].map(isPangram);
})();</syntaxhighlight>
{{Out}}
Line 1,687 ⟶ 2,358:
=={{header|jq}}==
<
explode
| map( if 65 <= . and . <= 90 then . + 32 # uppercase
Line 1,697 ⟶ 2,368:
# Example:
"The quick brown fox jumps over the lazy dog" | is_pangram</
{{Out}}
$ jq -M -n -f pangram.jq
Line 1,704 ⟶ 2,375:
=={{header|Julia}}==
<tt>makepangramchecker</tt> creates a function to test for pangramity based upon the contents of its input string, allowing one to create arbitrary pangram checkers.
<
alphabet = Set(uppercase.(alphabet))
function ispangram(s)
Line 1,723 ⟶ 2,394:
for s in tests
println("The sentence \"", s, "\" is ", is_english_pangram(s) ? "" : "not ", "a pangram.")
end</
{{out}}
Line 1,735 ⟶ 2,406:
=={{header|K}}==
{{works with|Kona}}
<syntaxhighlight lang="k">lcase : _ci 97+!26
ucase : _ci 65+!26
tolower : {@[x;p;:;lcase@n@p:&26>n:ucase?/:x]}
panagram: {&/lcase _lin tolower x}</
Example:
<
1
panagram "Panagram test"
0</
{{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}}==
<
fun isPangram(s: String): Boolean {
Line 1,755 ⟶ 2,435:
if (c !in t) return false
return true
}
fun main(args: Array<String>) {
Line 1,764 ⟶ 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")
}</
{{out}}
Line 1,776 ⟶ 2,456:
</pre>
=={{header|
<syntaxhighlight lang="ksh">
#!/bin/ksh
# Pangram checker
# # Variables:
#
alphabet='abcdefghijklmnopqrstuvwxyz'
typeset -a strs
strs+=( 'Mr. Jock, TV quiz PhD., bags few lynx.' )
strs+=( 'A very mad quack might jinx zippy fowls.' )
# # Functions:
#
# # Function _ispangram(str) - return 0 if str is a pangram
#
function _ispangram {
typeset _str ; typeset -l _str="$1"
typeset _buff ; _buff="${alphabet}"
typeset _i ; typeset -si _i
for ((_i=0; _i<${#_str} && ${#_buff}>0; _i++)); do
_buff=${_buff/${_str:${_i}:1}/}
done
return ${#_buff}
}
######
# main #
######
typeset -si i
for ((i=0; i<${#strs[*]}; i++)); do
_ispangram "${strs[i]}"
if (( ! $? )); then
print "${strs[i]} <<< IS A PANGRAM."
else
print "${strs[i]} <<< Is not a pangram."
fi
done
</syntaxhighlight>
{{out}}<pre>
Mr. Jock, TV quiz PhD., bags few lynx. <<< IS A PANGRAM.
A very mad quack might jinx zippy fowls. <<< Is not a pangram.
</pre>
=={{header|Logo}}==
<
if empty? :s [output :set]
if word? :s [output remove.all butfirst :s remove first :s :set]
Line 1,800 ⟶ 2,515:
end
show pangram? [The five boxing wizards jump quickly.] ; true</
=={{header|Lua}}==
<
S, C = lpeg.S, lpeg.C
function ispangram(s)
Line 1,811 ⟶ 2,526:
print(ispangram"waltz, bad nymph, for quick jigs vex")
print(ispangram"bobby")
print(ispangram"long sentence")</
=={{header|Maple}}==
<
is_pangram := proc(str)
local present := StringTools:-LowerCase~(select(StringTools:-HasAlpha, StringTools:-Explode(str)));
Line 1,821 ⟶ 2,536:
return evalb(present = alphabets);
end proc;
</syntaxhighlight>
{{out|Usage}}
<syntaxhighlight lang="text">is_pangram("The quick brown fox jumps over the lazy dog.");
is_pangram("The 2 QUIck brown foxes jumped over the lazy DOG!!");
is_pangram(""The quick brown fox jumps over the lay dog.");</
{{out|Output}}
<pre>
Line 1,833 ⟶ 2,548:
</pre>
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<
Usage:
<pre>pangramQ["The quick brown fox jumps over the lazy dog."]
Line 1,840 ⟶ 2,555:
Or a slightly more verbose version that outputs the missing characters if the string is not a pangram:
<
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]]]]</
Usage:
<pre>pangramQ["The quick brown fox jumps over the lazy dog."]
Line 1,852 ⟶ 2,567:
=={{header|MATLAB}}==
<
%This works by histogramming the ascii character codes for lower case
Line 1,863 ⟶ 2,578:
trueFalse = isempty(find( histc(lower(string),(97:122))==0,1 ));
end</
{{out}}
<
ans =
1</
=={{header|MATLAB}} / {{header|Octave}}==
<
% X is a histogram of letters
X = sparse(abs(lower(string)),1,1,128,1);
trueFalse = full(all(X('a':'z') > 0));
end</
{{out}}
Line 1,887 ⟶ 2,602:
=={{header|min}}==
{{works with|min|0.19.3}}
<
('alphabet dip lowercase (swap match) prepend all?) :pangram?
"The quick brown fox jumps over the lazy dog." pangram? puts</
=={{header|MiniScript}}==
<
"Peter Piper picked a peck of pickled peppers.",
"Waltz job vexed quick frog nymphs."]
alphabet = "abcdefghijklmnopqrstuvwxyz"
pangram = function (toCheck)
sentence = toCheck.lower
Line 1,907 ⟶ 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
end for</
{{out}}
<pre>
Line 1,924 ⟶ 2,639:
=={{header|ML}}==
==={{header|mLite}}===
<
fun is_pangram
(h :: t, T) =
let
val flen = len (filter (fn c = c eql h) T)
in
Line 1,936 ⟶ 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 1,949 ⟶ 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}}
<pre>'The quick brown fox jumps over the lazy dog' is a pangram
Line 1,967 ⟶ 2,682:
'Yxskaftbud, ge vår wczonmö iq hjälp' is a Swedish pangram
</pre>
=={{header|Modula-2}}==
<syntaxhighlight lang="modula2">MODULE Pangrams;
FROM InOut IMPORT WriteString, WriteLn;
FROM Strings IMPORT Length;
(* Check if a string is a pangram *)
PROCEDURE pangram(s: ARRAY OF CHAR): BOOLEAN;
VAR letters: ARRAY [0..25] OF BOOLEAN;
i: CARDINAL;
BEGIN
FOR i := 0 TO 25 DO letters[i] := FALSE; END;
FOR i := 0 TO Length(s)-1 DO
IF (s[i] >= 'A') AND (s[i] <= 'Z') THEN
letters[ORD(s[i]) - ORD('A')] := TRUE;
ELSIF (s[i] >= 'a') AND (s[i] <= 'z') THEN
letters[ORD(s[i]) - ORD('a')] := TRUE;
END;
END;
FOR i := 0 TO 25 DO
IF NOT letters[i] THEN
RETURN FALSE;
END;
END;
RETURN TRUE;
END pangram;
PROCEDURE example(s: ARRAY OF CHAR);
BEGIN
WriteString("'");
WriteString(s);
WriteString("' is ");
IF NOT pangram(s) THEN
WriteString("not ");
END;
WriteString("a pangram.");
WriteLn();
END example;
BEGIN
example("The quick brown fox jumps over the lazy dog");
example("The five boxing wizards dump quickly");
example("abcdefghijklmnopqrstuvwxyz");
END Pangrams.</syntaxhighlight>
{{out}}
<pre>'The quick brown fox jumps over the lazy dog' is a pangram.
'The five boxing wizards dump quickly' is not a pangram.
'abcdefghijklmnopqrstuvwxyz' is a pangram.</pre>
=={{header|NetRexx}}==
NetRexx's <code>verify</code> built–in method is all you need!
<
options replace format comments java crossref savelog symbols nobinary
Line 1,999 ⟶ 2,762:
return pangrams
</syntaxhighlight>
{{out}}
<pre style="overflow:scroll">
Line 2,010 ⟶ 2,773:
=={{header|NewLISP}}==
<
(context 'PGR) ;; Switch to context (say namespace) PGR
(define (is-pangram? str)
Line 2,029 ⟶ 2,792:
(println (PGR:is-pangram? "abcdef")) ;; Print nil
(exit)
</syntaxhighlight>
=={{header|Nim}}==
<
proc isPangram(sentence: string, alphabet = {'a'..'z'}): bool =
Line 2,039 ⟶ 2,802:
alphabet <= sentset
echo isPangram(readLineFromStdin "Sentence: ")</
Example usage:
<pre>Sentence: The quick brown fox jumps over the lazy dog
Line 2,046 ⟶ 2,809:
=={{header|Objeck}}==
{{trans|Java}}
<
bundle Default {
class Pangram {
Line 2,070 ⟶ 2,833:
}
}
</syntaxhighlight>
=={{header|OCaml}}==
<
let ar = Array.make 26 false in
String.iter (function
Line 2,080 ⟶ 2,843:
| _ -> ()
) (String.lowercase str);
Array.fold_left ( && ) true ar</
<
Printf.printf " %b -- %s\n" (pangram str) str
Line 2,088 ⟶ 2,851:
check "this is a sentence";
check "The quick brown fox jumps over the lazy dog.";
;;</
{{out}}
Line 2,095 ⟶ 2,858:
=={{header|Oz}}==
<
fun {IsPangram Xs}
{List.sub
Line 2,102 ⟶ 2,865:
end
in
{Show {IsPangram "The quick brown fox jumps over the lazy dog."}}</
=={{header|PARI/GP}}==
<
s=vecsort(Vec(s),,8);
for(i=97,122,
Line 2,116 ⟶ 2,879:
pangram("The quick brown fox jumps over the lazy dog.")
pangram("The quick brown fox jumps over the lazy doe.")</
=={{header|Pascal}}==
Line 2,123 ⟶ 2,886:
=={{header|Perl}}==
Get an answer with a module, or without.
<
use warnings;
use feature 'say';
Line 2,146 ⟶ 2,909:
say pangram1($_,@alpha) ? 'Yes' : 'No';
say pangram2($_,@alpha) ? 'Yes' : 'No';
}</
{{out}}
<pre>Yes
Line 2,154 ⟶ 2,917:
=={{header|Phix}}==
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #008080;">function</span> <span style="color: #000000;">pangram</span><span style="color: #0000FF;">(</span><span style="color: #004080;">string</span> <span style="color: #000000;">s</span><span style="color: #0000FF;">)</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">az</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #004600;">false</span><span style="color: #0000FF;">,</span><span style="color: #000000;">26</span><span style="color: #0000FF;">)</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">count</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">ch</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">lower</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">])</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">ch</span><span style="color: #0000FF;">>=</span><span style="color: #008000;">'a'</span>
<span style="color: #008080;">and</span> <span style="color: #000000;">ch</span><span style="color: #0000FF;"><=</span><span style="color: #008000;">'z'</span>
<span style="color: #008080;">and</span> <span style="color: #008080;">not</span> <span style="color: #000000;">az</span><span style="color: #0000FF;">[</span><span style="color: #000000;">ch</span><span style="color: #0000FF;">-</span><span style="color: #000000;">96</span><span style="color: #0000FF;">]</span> <span style="color: #008080;">then</span>
<span style="color: #000000;">count</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">count</span><span style="color: #0000FF;">=</span><span style="color: #000000;">26</span> <span style="color: #008080;">then</span> <span style="color: #008080;">return</span> <span style="color: #0000FF;">{</span><span style="color: #004600;">true</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">}</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #000000;">az</span><span style="color: #0000FF;">[</span><span style="color: #000000;">ch</span><span style="color: #0000FF;">-</span><span style="color: #000000;">96</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #004600;">true</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</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: #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;">".!$\"AbCdEfghijklmnoprqstuvwxyz"</span><span style="color: #0000FF;">,</span>
<span style="color: #008000;">"THE FIVE BOXING WIZARDS DUMP QUICKLY."</span><span style="color: #0000FF;">,</span>
<span style="color: #008000;">"THE FIVE BOXING WIZARDS JUMP QUICKLY."</span><span style="color: #0000FF;">,</span>
<span style="color: #008000;">"HEAVY BOXES PERFORM WALTZES AND JIGS."</span><span style="color: #0000FF;">,</span>
<span style="color: #008000;">"PACK MY BOX WITH FIVE DOZEN LIQUOR JUGS."</span><span style="color: #0000FF;">,</span>
<span style="color: #008000;">"Big fjiords vex quick waltz nymph"</span><span style="color: #0000FF;">,</span>
<span style="color: #008000;">"The quick onyx goblin jumps over the lazy dwarf."</span><span style="color: #0000FF;">,</span>
<span style="color: #008000;">"no"</span><span style="color: #0000FF;">}</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">checks</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
<span style="color: #004080;">string</span> <span style="color: #000000;">ci</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">checks</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]</span>
<span style="color: #004080;">integer</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">r</span><span style="color: #0000FF;">,</span><span style="color: #000000;">ch</span><span style="color: #0000FF;">}</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">pangram</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ci</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%-50s - %s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">ci</span><span style="color: #0000FF;">,</span><span style="color: #008080;">iff</span><span style="color: #0000FF;">(</span><span style="color: #000000;">r</span><span style="color: #0000FF;">?</span><span style="color: #008000;">"yes"</span><span style="color: #0000FF;">:</span><span style="color: #008000;">"no "</span><span style="color: #0000FF;">&</span><span style="color: #000000;">ch</span><span style="color: #0000FF;">)})</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--</syntaxhighlight>-->
{{out}}
<pre>
Line 2,198 ⟶ 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}}==
{{trans|D}}
<
foreach (str_split($text) as $c) {
if ($c >= 'a' && $c <= 'z')
Line 2,220 ⟶ 3,004:
foreach ($test as $str)
echo "$str : ", isPangram($str) ? 'T' : 'F', '</br>';</
<pre>the quick brown fox jumps over the lazy dog : T
Line 2,230 ⟶ 3,014:
Using array
<
// define "alphabet"
Line 2,257 ⟶ 3,041:
echo is_pangram( $txt ) ? "Yes" : "No", PHP_EOL, PHP_EOL;
}
</syntaxhighlight>
{{Out}}
Line 2,283 ⟶ 3,067:
Yes
</pre>
=={{header|Picat}}==
<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)]),
nl,
println("With missing chars:"),
println([S1, is_pangram2(S1)]),
println([S2, is_pangram2(S2)]),
nl.
% Check if S is a pangram and get the missing chars
is_pangram(S) = P =>
Lower = S.to_lowercase,
Alpha = [chr(I+96) : I in 1..26],
foreach(A in Alpha) membchk(A,Lower) end -> P = true ; P = false.
% Check if S is a pangram and get the missing chars (if any)
is_pangram2(S) = [pangram=cond(Missing==[],true,false),missing=Missing] =>
Lower = S.to_lowercase,
Missing = [A : A in [chr(I+96) : I in 1..26], not membchk(A,Lower)].</syntaxhighlight>
{{out}}
<pre>[The quick brown fox jumps over the lazy dog,true]
[The slow brown fox jumps over the lazy dog,false]
With missing chars:
[The quick brown fox jumps over the lazy dog,[pangram = true,missing = []]]
[The slow brown fox jumps over the lazy dog,[pangram = false,missing = cikq]]</pre>
=={{header|PicoLisp}}==
<
(not
(diff
'`(chop "abcdefghijklmnopqrstuvwxyz")
(chop (lowc Str)) ) ) )</
=={{header|PL/I}}==
<syntaxhighlight lang="pl/i">
test_pangram: procedure options (main);
Line 2,321 ⟶ 3,136:
end test_pangram;
</syntaxhighlight>
{{out}}
<pre>
Please type a sentence
the quick brown fox jumps over the lazy dog
The sentence is a pangram.
</pre>
Line 2,334 ⟶ 3,149:
Cyrillic test sample borrowed from Raku.
{{works with|PowerShell|2}}
<syntaxhighlight lang="powershell">
function Test-Pangram ( [string]$Text, [string]$Alphabet = 'abcdefghijklmnopqrstuvwxyz' )
{
$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.'
Test-Pangram 'Съешь же ещё этих мягких французских булок, да выпей чаю' 'абвгдежзийклмнопрстуфхцчшщъыьэюяё'
</syntaxhighlight>
{{out}}
<pre>
Line 2,356 ⟶ 3,171:
</pre>
A faster version can be created using .Net HashSet to do what the F# version does:
<syntaxhighlight lang="powershell">
Function Test-Pangram ( [string]$Text, [string]$Alphabet = 'abcdefghijklmnopqrstuvwxyz' )
{
Line 2,366 ⟶ 3,181:
return $alSet.Count -eq 0 # any alphabet letters still remaining?
}
</syntaxhighlight>
=={{header|Prolog}}==
Works with SWI-Prolog
<
numlist(0'a, 0'z, Alphabet),
forall(member(C, Alphabet), member(C, L)).
Line 2,383 ⟶ 3,198:
( pangram(L2) -> R2 = ok; R2 = ko),
format('~s --> ~w ~n', [L2, R2]).
</syntaxhighlight>
{{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|Python}}==
Using set arithmetic:
<
if sys.version_info[0] < 3:
input = raw_input
Line 2,433 ⟶ 3,215:
return alphaset <= set(sentence.lower())
print ( ispangram(input('Sentence: ')) )</
{{out}}
<pre>Sentence: The quick brown fox jumps over the lazy dog
True</pre>
=={{header|Quackery}}==
<syntaxhighlight lang="quackery">
[ dup char A char [ within
swap char a char { within
or ] is letter ( c --> b )
[ 0 26 of swap witheach
[ dup letter iff
[ 1 unrot lower
char a - poke ]
else drop ]
0 swap find 26 = ] is pangram ( $ --> b )
$ "This is a sentence." pangram echo cr ( 0 )
$ "The five boxing wizards jumped quickly." pangram echo cr ( 1 )
</syntaxhighlight>
=={{header|R}}==
Using the built-in R vector "letters":
<
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,451 ⟶ 3,250:
}
}
</
{{out}}
Line 2,464 ⟶ 3,263:
=={{header|Racket}}==
<syntaxhighlight lang="racket">
#lang racket
(define (pangram? str)
Line 2,470 ⟶ 3,269:
(= 26 (length (remove-duplicates (string->list chars)))))
(pangram? "The quick Brown Fox jumps over the Lazy Dog")
</syntaxhighlight>
=={{header|Raku}}==
(formerly Perl 6)
<syntaxhighlight lang="raku"
constant Cyr = (set
constant Hex = set 'a' .. 'f';
sub pangram($str, Set $alpha = Eng) {
$alpha ⊆ $str.lc.comb
}
Line 2,486 ⟶ 3,285:
say pangram("My dog has fleas.", Hex);
say pangram("My dog backs fleas.", Hex);
say pangram "Съешь же ещё этих мягких французских булок, да выпей чаю", Cyr;</
{{out}}
<pre>True
Line 2,495 ⟶ 3,294:
=={{header|Retro}}==
<
'__________________________ 'TEST s:const
:s:pangram? (s-f)
Line 2,502 ⟶ 3,301:
[ dup $a - &TEST + store ] s:for-each
&TEST &FULL s:eq? ;
</syntaxhighlight>
=={{header|REXX}}==
<
@abc= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' /*a list of all (Latin) capital letters*/
Line 2,518 ⟶ 3,317:
end /*forever*/
say '──────── PANGRAM program ended. ────────' /*stick a fork in it, we're all done. */</
{{out|output|:}}
<pre>
Line 2,532 ⟶ 3,331:
──────── Please enter a pangramic sentence (or a blank to quit):
◄■■■■■■■■■■ user input (null or some blanks).
──────── PANGRAM program ended. ────────
Line 2,538 ⟶ 3,337:
=={{header|Ring}}==
<
pangram = 0
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 2,551 ⟶ 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}}==
<
('a'..'z').all? {|char| s.include? (char) }
end
p pangram?('this is a sentence') # ==> false
p pangram?('The quick brown fox jumps over the lazy dog.') # ==> true</
=={{header|Rust}}==
<
extern crate test;
Line 2,649 ⟶ 3,495:
is_pangram_hashset);
}
}</
=={{header|Scala}}==
<
</syntaxhighlight>
<
scala> is_pangram("This is a sentence")
res0: Boolean = false
Line 2,661 ⟶ 3,507:
scala> is_pangram("The quick brown fox jumps over the lazy dog")
res1: Boolean = true
</syntaxhighlight>
=={{header|Seed7}}==
<
const func boolean: isPangram (in string: stri) is func
Line 2,687 ⟶ 3,533:
writeln(isPangram("NOPQRSTUVWXYZ abcdefghijklm"));
writeln(isPangram("abcdefghijklopqrstuvwxyz")); # Missing m, n
end func;</
{{out}}
Line 2,699 ⟶ 3,545:
=={{header|Sidef}}==
{{trans|Raku}}
<
define Hex = 'a'..'f';
define Cyr = %w(а б в г д е ж з и й к л м н о п р с т у ф х ц ч ш щ ъ ы ь э ю я ё);
Line 2,712 ⟶ 3,558:
say pangram("My dog has fleas.", Hex);
say pangram("My dog backs fleas.", Hex);
say pangram("Съешь же ещё этих мягких французских булок, да выпей чаю", Cyr);</
{{out}}
<pre>
Line 2,723 ⟶ 3,569:
=={{header|Smalltalk}}==
<
isPangram
^((self collect: [:c | c asUppercase]) select: [:c | c >= $A and: [c <= $Z]]) asSet size = 26
</syntaxhighlight>
<
'The quick brown fox jumps over the lazy dog.' isPangram
</syntaxhighlight>
=={{header|SNOBOL4}}==
Line 2,738 ⟶ 3,584:
{{works with|CSnobol}}
<
pangram str = replace(str,&ucase,&lcase)
alfa = &lcase
Line 2,746 ⟶ 3,592:
define('panchk(str)tf') :(panchk_end)
panchk output = str
tf = 'False'; tf = pangram(str) 'True'
output = 'Pangram: ' tf :(return)
Line 2,755 ⟶ 3,601:
panchk("My girl wove six dozen plaid jackets before she quit.")
panchk("This 41-character string: it's a pangram!")
end</
{{out}}
Line 2,766 ⟶ 3,612:
=={{header|Swift}}==
<
let str = "the quick brown fox jumps over the lazy dog"
Line 2,781 ⟶ 3,627:
isPangram(str) // True
isPangram("Test string") // False</
Swift 2.0:
<
let (char, alph) = (Set(str.characters), "abcdefghijklmnopqrstuvwxyz".characters)
return !alph.contains {!char.contains($0)}
}</
=={{header|Tcl}}==
<
set letters [regexp -all -inline {[a-z]} [string tolower $sentence]]
expr {
Line 2,797 ⟶ 3,643:
}
puts [pangram? "This is a sentence"]; # ==> false
puts [pangram? "The quick brown fox jumps over the lazy dog."]; # ==> true</
=={{header|TI-83 BASIC}}==
<
:For(L,1,26
:If not(inString(Str1,sub("ABCDEFGHIJKLMNOPQRSTUVWXYZ",L,1))
Line 2,806 ⟶ 3,652:
:End
:If L<28
:Disp "IS A PANGRAM"</
(not tested yet)
=={{header|TUSCRIPT}}==
<
$$ MODE TUSCRIPT,{}
alfabet="abcdefghijklmnopqrstuvwxyz"
Line 2,824 ⟶ 3,670:
IF (chars_in_s!=alfabet) PRINT "no pangram: ",s
ENDLOOP
</syntaxhighlight>
{{out}}
<pre>
Line 2,832 ⟶ 3,678:
=={{header|TXR}}==
<
.*[Ee].*&.*[Ff].*&.*[Gg].*&.*[Hh].*& \
.*[Ii].*&.*[Jj].*&.*[Kk].*&.*[Ll].*& \
Line 2,838 ⟶ 3,684:
.*[Qq].*&.*[Rr].*&.*[Ss].*&.*[Tt].*& \
.*[Uu].*&.*[Vv].*&.*[Ww].*&.*[Xx].*& \
.*[Yy].*&.*[Zz].*/</
{{out|Run}}
Line 2,850 ⟶ 3,696:
=={{header|UNIX Shell}}==
{{works with|Bourne Again SHell}}
{{works with|Korn Shell}}
{{works with|Z Shell}}
<syntaxhighlight lang="bash">function is_pangram {
typeset alphabet=abcdefghijklmnopqrstuvwxyz
while [[
alphabet=${alphabet/$ch}
done
[[ -z
}</
=={{header|Ursala}}==
<syntaxhighlight lang="ursala">
#import std
is_pangram = ^jZ^(!@l,*+ @rlp -:~&) ~=`A-~ letters
</syntaxhighlight>
example usage:
<syntaxhighlight lang="ursala">
#cast %bL
test =
is_pangram* <
'The quick brown fox jumps over the lazy dog',
'this is not a pangram'>
</syntaxhighlight>
{{out}}
<pre>
Line 2,888 ⟶ 3,735:
Here is an alternative version:
<syntaxhighlight lang="vb">
Function pangram2(s As String) As Boolean
Const sKey As String = "abcdefghijklmnopqrstuvwxyz"
Dim sLow As String
Dim i As Integer
sLow = LCase(s)
For i = 1 To 26
Line 2,903 ⟶ 3,750:
pangram2 = True
End Function
</syntaxhighlight>
Invocation e.g. (typed in the Immediate window):
Line 2,913 ⟶ 3,760:
=={{header|VBScript}}==
====Implementation====
<
dim i
dim sKey
Line 2,934 ⟶ 3,781:
pangram = ( ltrim(sKey) = vbnullstring )
end function
function eef( bCond, exp1, exp2 )
if bCond then
Line 2,941 ⟶ 3,788:
eef = exp2
end if
end function</
====Invocation====
<
wscript.echo eef(pangram(""), "is a pangram", "is not a pangram")"</
=={{header|VTL-2}}==
<syntaxhighlight lang="vtl2">10 I=1
20 :I)=0
30 I=I+1
40 #=26>I*20
50 ?="Enter sentence: ";
60 C=$
70 #=C=13*120
80 C=C<97*32+C-96
90 #=C>27*60
100 :C)=1
110 #=60
120 ?=""
130 I=1
140 N=0
150 N=N+:I)
160 I=I+1
170 #=26>I*150
180 #=N=26*200
190 ?="not ";
200 ?="a pangram"</syntaxhighlight>
{{out}}
<pre>#=1
Enter sentence: The quick brown fox jumps over the lazy dog.
a pangram
OK
#=1
Enter sentence: This is not a pangram.
not a pangram
OK</pre>
=={{header|Wren}}==
{{libheader|Wren-str}}
<
var isPangram = Fn.new { |s|
Line 2,973 ⟶ 3,853:
for (candidate in candidates) {
System.print(" %(candidate) -> %(isPangram.call(candidate))")
}</
{{out}}
Line 2,987 ⟶ 3,867:
=={{header|XPL0}}==
<
string 0; \use zero-terminated strings
Line 3,017 ⟶ 3,897:
CrLf(0);
];
]</
{{out}}
Line 3,025 ⟶ 3,905:
no
</pre>
=={{header|zkl}}==
<
fcn isPangram(text){(not (letters-text.toLower()))}</
{{out}}
<pre>
|