Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,4 @@
---
category:
- String manipulation
from: http://rosettacode.org/wiki/Pangram_checker

View file

@ -0,0 +1,14 @@
A pangram is a sentence that contains all the letters of the English alphabet at least once.
For example:   ''The quick brown fox jumps over the lazy dog''.
;Task:
Write a function or method to check a sentence to see if it is a   [[wp:Pangram|pangram]]   (or not)   and show its use.
;Related tasks:
:*   [https://rosettacode.org/wiki/Determine_if_a_string_has_all_the_same_characters determine if a string has all the same characters]
:*   [https://rosettacode.org/wiki/Determine_if_a_string_has_all_unique_characters determine if a string has all unique characters]
<br><br>

View file

@ -0,0 +1,6 @@
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)))

View file

@ -0,0 +1,38 @@
* Pangram RC 11/08/2015
PANGRAM CSECT
USING PANGRAM,R12
LR R12,R15
BEGIN LA R9,SENTENCE
LA R6,4
LOOPI LA R10,ALPHABET loop on sentences
LA R7,26
LOOPJ LA R5,0 loop on letters
LR R11,R9
LA R8,60
LOOPK MVC BUFFER+1(1),0(R10) loop in sentence
CLC 0(1,R10),0(R11) if alphabet[j=sentence[i]
BNE NEXTK
LA R5,1 found
NEXTK LA R11,1(R11) next character
BCT R8,LOOPK
LTR R5,R5 if found
BNZ NEXTJ
MVI BUFFER,C'?' not found
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
ALPHABET DC CL26'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
SENTENCE DC CL60'THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.'
DC CL60'THE FIVE BOXING WIZARDS DUMP QUICKLY.'
DC CL60'HEAVY BOXES PERFORM WALTZES AND JIGS.'
DC CL60'PACK MY BOX WITH FIVE DOZEN LIQUOR JUGS.'
BUFFER DC CL80' '
YREGS
END PANGRAM

View file

@ -0,0 +1,9 @@
(defun contains-each (needles haystack)
(if (endp needles)
t
(and (member (first needles) haystack)
(contains-each (rest needles) haystack))))
(defun pangramp (str)
(contains-each (coerce "abcdefghijklmnopqrstuvwxyz" 'list)
(coerce (string-downcase str) 'list)))

View file

@ -0,0 +1,36 @@
# init pangram: #
INT la = ABS "a", lz = ABS "z";
INT ua = ABS "A", uz = ABS "Z";
IF lz-la+1 > bits width THEN
put(stand error, "Exception: insufficient bits in word for task");
stop
FI;
PROC is a pangram = (STRING test)BOOL: (
BITS a2z := BIN(ABS(2r1 SHL (lz-la))-1); # assume: ASCII & Binary #
FOR i TO UPB test WHILE
INT c = ABS test[i];
IF la <= c AND c <= lz THEN
a2z := a2z AND NOT(2r1 SHL (c-la))
ELIF ua <= c AND c <= uz THEN
a2z := a2z AND NOT(2r1 SHL (c-ua))
FI;
# WHILE # a2z /= 2r0 DO
SKIP
OD;
a2z = 2r0
);
main:(
[]STRING test list = (
"Big fjiords vex quick waltz nymph",
"The quick brown fox jumps over a lazy dog",
"A quick brown fox jumps over a lazy dog"
);
FOR key TO UPB test list DO
STRING test = test list[key];
IF is a pangram(test) THEN
print(("""",test,""" is a pangram!", new line))
FI
OD
)

View file

@ -0,0 +1,8 @@
a'abcdefghijklmnopqrstuvwxyz' ⍝ or ⎕ucs 96 + 26 in GNU/Dyalog
A'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ⍝ or ⎕ucs 64 + 26, or just ⎕a in Dyalog
Pangram {/ 2 26(a,A) }
Pangram 'This should fail'
0
Pangram 'The quick brown fox jumps over the lazy dog'
1

View file

@ -0,0 +1,45 @@
(* ****** ****** *)
//
#include
"share/atspre_staload.hats"
#include
"share/HATS/atspre_staload_libats_ML.hats"
//
(* ****** ****** *)
//
fun
letter_check
(
cs: string, c0: char
) : bool = cs.exists()(lam(c) => c0 = c)
//
(* ****** ****** *)
fun
Pangram_check
(text: string): bool = let
//
val
alphabet = "abcdefghijklmnopqrstuvwxyz"
val
((*void*)) = assertloc(length(alphabet) = 26)
//
in
alphabet.forall()(lam(c) => letter_check(text, c) || letter_check(text, toupper(c)))
end // end of [Pangram_check]
(* ****** ****** *)
implement
main0 () =
{
//
val
text0 = "The quick brown fox jumps over the lazy dog."
//
val-true = Pangram_check(text0)
val-false = Pangram_check("This is not a pangram sentence.")
//
} (* end of [main0] *)
(* ****** ****** *)

View file

@ -0,0 +1,19 @@
fn is_pangram{n:nat}(s: string(n)): bool = loop(s, i2sz(0)) where {
val letters: arrayref(bool, 26) = arrayref_make_elt<bool>(i2sz(26), false)
fn check(): bool = loop(0) where {
fun loop{i:int | i >= 0 && i <= 26}(i: int(i)) =
if i < 26 then
if letters[i] then loop(i+1) else
false
else true
}
fun add{c:int}(c: char(c)): void =
if (c >= 'A') * (c <= 'Z') then letters[char2int1(c) - char2int1('A')] := true else
if (c >= 'a') * (c <= 'z') then letters[char2int1(c) - char2int1('a')] := true
fun loop{i:nat | i <= n}.<n-i>.(s: string(n), i: size_t(i)): bool =
if string_is_atend(s, i) then check() else
begin
add(s[i]);
loop(s, succ(i))
end
}

View file

@ -0,0 +1,17 @@
#!/usr/bin/awk -f
BEGIN {
allChars="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
print isPangram("The quick brown fox jumps over the lazy dog.");
print isPangram("The quick brown fo.");
}
function isPangram(string) {
delete X;
for (k=1; k<length(string); k++) {
X[toupper(substr(string,k,1))]++; # histogram
}
for (k=1; k<=length(allChars); k++) {
if (!X[substr(allChars,k,1)]) return 0;
}
return 1;
}

View file

@ -0,0 +1,29 @@
# usage: awk -f pangram.awk -v p="The five boxing wizards dump quickly." input.txt
#
# Pangram-checker, using associative arrays and split
BEGIN {
alfa="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; ac=split(alfa,A,"")
print "# Checking for all",ac,"chars in '" alfa "' :"
print testPangram("The quick brown fox jumps over the lazy dog.");
print testPangram(p);
}
{ print testPangram($0) }
function testPangram(str, c,i,S,H,hit,miss) {
print str ##
split( toupper(str), S, "")
for (c in S) {
H[ S[c] ]++
#print c, S[c], H[ S[c] ] ##
}
for (i=1; i<=ac; i++) {
c = A[i]
#printf("%2d %c : %4d\n", i, c, H[c] ) ##
if (H[c]) { hit=hit c } else { miss=miss c }
}
print "# hit:",hit, "# miss:",miss, "." ##
if (miss) return 0
return 1
}

View file

@ -0,0 +1,46 @@
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

View file

@ -0,0 +1,16 @@
function pangram(k:string):Boolean {
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;
}

View file

@ -0,0 +1,14 @@
with Ada.Text_IO; use Ada.Text_IO;
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")));
put_line(Boolean'Image(ispangram("The quick brown fox jumps over the lazy dog")));
put_line(Boolean'Image(ispangram("NOPQRSTUVWXYZ abcdefghijklm")));
put_line(Boolean'Image(ispangram("abcdefghijklopqrstuvwxyz"))); --Missing m, n
end pangram;

View file

@ -0,0 +1,14 @@
with Ada.Text_IO; use Ada.Text_IO;
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' =>
(for some Char of txt => To_Lower(Char) = Letter));
begin
put_line(Boolean'Image(ispangram("This is a test")));
put_line(Boolean'Image(ispangram("The quick brown fox jumps over the lazy dog")));
put_line(Boolean'Image(ispangram("NOPQRSTUVWXYZ abcdefghijklm")));
put_line(Boolean'Image(ispangram("abcdefghijklopqrstuvwxyz"))); --Missing m, n
end pangram;

View file

@ -0,0 +1,77 @@
use framework "Foundation" -- ( for case conversion function )
--------------------- PANGRAM CHECKER --------------------
-- isPangram :: String -> Bool
on isPangram(s)
script charUnUsed
property lowerCaseString : my toLower(s)
on |λ|(c)
lowerCaseString does not contain c
end |λ|
end script
0 = length of filter(charUnUsed, ¬
"abcdefghijklmnopqrstuvwxyz")
end isPangram
--------------------------- TEST -------------------------
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]
on filter(f, xs)
tell mReturn(f)
set lst to {}
set lng to length of xs
repeat with i from 1 to lng
set v to item i of xs
if |λ|(v, i, xs) then set end of lst to v
end repeat
return lst
end tell
end filter
-- map :: (a -> b) -> [a] -> [b]
on map(f, xs)
tell mReturn(f)
set lng to length of xs
set lst to {}
repeat with i from 1 to lng
set end of lst to |λ|(item i of xs, i, xs)
end repeat
return lst
end tell
end map
-- Lift 2nd class handler function into
-- 1st class script wrapper
-- mReturn :: Handler -> Script
on mReturn(f)
if class of f is script then
f
else
script
property |λ| : f
end script
end if
end mReturn
-- toLower :: String -> String
on toLower(str)
set ca to current application
((ca's NSString's stringWithString:(str))'s ¬
lowercaseStringWithLocale:(ca's NSLocale's currentLocale())) as text
end toLower

View file

@ -0,0 +1 @@
{false, true}

View file

@ -0,0 +1,15 @@
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}

View file

@ -0,0 +1 @@
{true, false}

View file

@ -0,0 +1,16 @@
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

View file

@ -0,0 +1,8 @@
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."

View file

@ -0,0 +1,19 @@
Gui, -MinimizeBox
Gui, Add, Edit, w300 r5 vText
Gui, Add, Button, x105 w100 Default, Check Pangram
Gui, Show,, Pangram Checker
Return
GuiClose:
ExitApp
Return
ButtonCheckPangram:
Gui, Submit, NoHide
Loop, 26
If Not InStr(Text, Char := Chr(64 + A_Index)) {
MsgBox,, Pangram, Character %Char% is missing!
Return
}
MsgBox,, Pangram, OK`, this is a Pangram!
Return

View file

@ -0,0 +1,9 @@
Pangram("The quick brown fox jumps over the lazy dog")
Func Pangram($s_String)
For $i = 1 To 26
IF Not StringInStr($s_String, Chr(64 + $i)) Then
Return MsgBox(0,"No Pangram", "Character " & Chr(64 + $i) &" is missing")
EndIf
Next
Return MsgBox(0,"Pangram", "Sentence is a Pangram")
EndFunc

View file

@ -0,0 +1,14 @@
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

View file

@ -0,0 +1,29 @@
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$

View file

@ -0,0 +1,28 @@
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 do letters!i := false
for i=1 to s%0 do
$( let c = (s%i | 32) - 'a'
if c >= 0 & c < 26 then
letters!c := true
$)
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 pangram(s)
then writes("yes*N")
else writes("no*N")
$)
let start() be
$( check("The quick brown fox jumps over the lazy dog.")
check("The five boxing wizards dump quickly.")
$)

View file

@ -0,0 +1,7 @@
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")

View file

@ -0,0 +1,30 @@
@echo off
setlocal enabledelayedexpansion
%===The Main Thing===%
call :pangram "The quick brown fox jumps over the lazy dog."
call :pangram "The quick brown fox jumped over the lazy dog."
echo.
pause
exit /b 0
%===The Function===%
:pangram
set letters=abcdefgihjklmnopqrstuvwxyz
set cnt=0
set inp=%~1
set str=!inp: =!
:loop
set chr=!str:~%cnt%,1!
if "!letters!"=="" (
echo %1 is a pangram^^!
goto :EOF
)
if "!chr!"=="" (
echo %1 is not a pangram.
goto :EOF
)
set letters=!letters:%chr%=!
set /a cnt+=1
goto loop

View file

@ -0,0 +1,4 @@
>~>:65*`!#v_:"`"`48*v>g+04p1\4p
^#*`\*93\`0<::-"@"-*<^40!%2g4:_
"pangram."<v*84<_v#-":"g40\" a"
>>:#,_55+,@>"ton">48*>"si tahT"

View file

@ -0,0 +1,11 @@
(isPangram=
k
. low$!arg:?arg
& a:?k
& whl
' ( @(!arg:? !k ?)
& chr$(1+asc$!k):?k:~>z
)
& !k:>z
&
);

View file

@ -0,0 +1,15 @@
pangram? = { sentence |
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]
sentence.downcase!
letters.reject! { l |
sentence.include? l
}
letters.empty?
}
p pangram? 'The quick brown fox jumps over the lazy dog.' #Prints true
p pangram? 'Probably not a pangram.' #Prints false

View file

@ -0,0 +1,3 @@
pangram? = { sentence |
sentence.downcase.dice.unique.select(:alpha?).length == 26
}

View file

@ -0,0 +1,24 @@
#include <algorithm>
#include <cctype>
#include <string>
#include <iostream>
const std::string alphabet("abcdefghijklmnopqrstuvwxyz");
bool is_pangram(std::string s)
{
std::transform(s.begin(), s.end(), s.begin(), ::tolower);
std::sort(s.begin(), s.end());
return std::includes(s.begin(), s.end(), alphabet.begin(), alphabet.end());
}
int main()
{
const auto examples = {"The quick brown fox jumps over the lazy dog",
"The quick white cat jumps over the lazy dog"};
std::cout.setf(std::ios::boolalpha);
for (auto& text : examples) {
std::cout << "Is \"" << text << "\" a pangram? - " << is_pangram(text) << std::endl;
}
}

View file

@ -0,0 +1,15 @@
using System;
using System.Linq;
static class Program
{
static bool IsPangram(this string text, string alphabet = "abcdefghijklmnopqrstuvwxyz")
{
return alphabet.All(text.ToLower().Contains);
}
static void Main(string[] arguments)
{
Console.WriteLine(arguments.Any() && arguments.First().IsPangram());
}
}

View file

@ -0,0 +1,40 @@
using System;
namespace PangrammChecker
{
public class PangrammChecker
{
public static bool IsPangram(string str)
{
bool[] isUsed = new bool[26];
int ai = (int)'a';
int total = 0;
for (CharEnumerator en = str.ToLower().GetEnumerator(); en.MoveNext(); )
{
int d = (int)en.Current - ai;
if (d >= 0 && d < 26)
if (!isUsed[d])
{
isUsed[d] = true;
total++;
}
}
return (total == 26);
}
}
class Program
{
static void Main(string[] args)
{
string str1 = "The quick brown fox jumps over the lazy dog.";
string str2 = "The qu1ck brown fox jumps over the lazy d0g.";
Console.WriteLine("{0} is {1}a pangram", str1,
PangrammChecker.IsPangram(str1)?"":"not ");
Console.WriteLine("{0} is {1}a pangram", str2,
PangrammChecker.IsPangram(str2)?"":"not ");
Console.WriteLine("Press Return to exit");
Console.ReadLine();
}
}
}

View file

@ -0,0 +1,41 @@
#include <stdio.h>
int is_pangram(const char *s)
{
const char *alpha = ""
"abcdefghjiklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char ch, wasused[26] = {0};
int total = 0;
while ((ch = *s++) != '\0') {
const char *p;
int idx;
if ((p = strchr(alpha, ch)) == NULL)
continue;
idx = (p - alpha) % 26;
total += !wasused[idx];
wasused[idx] = 1;
if (total == 26)
return 1;
}
return 0;
}
int main(void)
{
int i;
const char *tests[] = {
"The quick brown fox jumps over the lazy dog.",
"The qu1ck brown fox jumps over the lazy d0g."
};
for (i = 0; i < 2; i++)
printf("\"%s\" is %sa pangram\n",
tests[i], is_pangram(tests[i])?"":"not ");
return 0;
}

View file

@ -0,0 +1,23 @@
#include <stdio.h>
int pangram(const char *s)
{
int c, mask = (1 << 26) - 1;
while ((c = (*s++)) != '\0') /* 0x20 converts lowercase to upper */
if ((c &= ~0x20) <= 'Z' && c >= 'A')
mask &= ~(1 << (c - 'A'));
return !mask;
}
int main()
{
int i;
const char *s[] = { "The quick brown fox jumps over lazy dogs.",
"The five boxing wizards dump quickly.", };
for (i = 0; i < 2; i++)
printf("%s: %s\n", pangram(s[i]) ? "yes" : "no ", s[i]);
return 0;
}

View file

@ -0,0 +1,32 @@
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

View file

@ -0,0 +1,51 @@
identification division.
program-id. pan-test.
data division.
working-storage section.
1 text-string pic x(80).
1 len binary pic 9(4).
1 trailing-spaces binary pic 9(4).
1 pangram-flag pic x value "n".
88 is-not-pangram value "n".
88 is-pangram value "y".
procedure division.
begin.
display "Enter text string:"
accept text-string
set is-not-pangram to true
initialize trailing-spaces len
inspect function reverse (text-string)
tallying trailing-spaces for leading space
len for characters after space
call "pangram" using pangram-flag len text-string
cancel "pangram"
if is-pangram
display "is a pangram"
else
display "is not a pangram"
end-if
stop run
.
end program pan-test.
identification division.
program-id. pangram.
data division.
1 lc-alphabet pic x(26) value "abcdefghijklmnopqrstuvwxyz".
linkage section.
1 pangram-flag pic x.
88 is-not-pangram value "n".
88 is-pangram value "y".
1 len binary pic 9(4).
1 text-string pic x(80).
procedure division using pangram-flag len text-string.
begin.
inspect lc-alphabet converting
function lower-case (text-string (1:len))
to space
if lc-alphabet = space
set is-pangram to true
end-if
exit program
.
end program pangram.

View file

@ -0,0 +1,17 @@
shared void run() {
function pangram(String sentence) =>
let(alphabet = set('a'..'z'),
letters = set(sentence.lowercased.filter(alphabet.contains)))
letters == alphabet;
value sentences = [
"The quick brown fox jumps over the lazy dog",
"""Watch "Jeopardy!", Alex Trebek's fun TV quiz game.""",
"Pack my box with five dozen liquor jugs.",
"blah blah blah"
];
for(sentence in sentences) {
print("\"``sentence``\" is a pangram? ``pangram(sentence)``");
}
}

View file

@ -0,0 +1,3 @@
(defn pangram? [s]
(let [letters (into #{} "abcdefghijklmnopqrstuvwxyz")]
(= (->> s .toLowerCase (filter letters) (into #{})) letters)))

View file

@ -0,0 +1,34 @@
is_pangram = (s) ->
# This is optimized for longish strings--as soon as all 26 letters
# are encountered, we will be done. Our worst case scenario is a really
# long non-pangram, or a really long pangram with at least one letter
# only appearing toward the end of the string.
a_code = 'a'.charCodeAt(0)
required_letters = {}
for i in [a_code...a_code+26]
required_letters[String.fromCharCode(i)] = true
cnt = 0
for c in s
c = c.toLowerCase()
if required_letters[c]
cnt += 1
return true if cnt == 26
delete required_letters[c]
false
do ->
tests = [
["is this a pangram", false]
["The quick brown fox jumps over the lazy dog", true]
]
for test in tests
[s, exp_value] = test
throw Error("fail") if is_pangram(s) != exp_value
# try long strings
long_str = ''
for i in [1..500000]
long_str += s
throw Error("fail") if is_pangram(long_str) != exp_value
console.log "Passed tests: #{s}"

View file

@ -0,0 +1,16 @@
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."

View file

@ -0,0 +1,33 @@
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

View file

@ -0,0 +1,4 @@
(defun pangramp (s)
(null (set-difference
(loop for c from (char-code #\A) upto (char-code #\Z) collect (code-char c))
(coerce (string-upcase s) 'list))))

View file

@ -0,0 +1,48 @@
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;
resp := resp & status[i]
END;
RETURN resp;
END Check;
PROCEDURE Do*;
VAR
params: DevCommanders.Par;
s: TextMappers.Scanner;
BEGIN
params := DevCommanders.par;
s.ConnectTo(params.text);
s.SetPos(params.beg);
s.Scan;
WHILE (~s.rider.eot) DO
IF (s.type = TextMappers.char) & (s.char = '~') THEN
RETURN
ELSIF (s.type # TextMappers.string) THEN
StdLog.String("Invalid parameter");StdLog.Ln
ELSE
StdLog.Char("'");StdLog.String(s.string + "' is pangram?:> ");
StdLog.Bool(Check(s.string));StdLog.Ln
END;
s.Scan
END
END Do;
END BbtPangramChecker.

View file

@ -0,0 +1,36 @@
include "cowgol.coh";
sub pangram(str: [uint8]): (r: uint8) is
var letters: uint8[26];
MemZero(&letters[0], 26);
loop
var chr := [str];
if chr == 0 then break; end if;
str := @next str;
chr := (chr | 32) - 'a';
if chr >= 26 then continue; end if;
letters[chr] := letters[chr] | 1;
end loop;
r := 1;
chr := 0;
while chr < 26 loop
r := r & letters[chr];
if r == 0 then break; end if;
chr := chr + 1;
end loop;
end sub;
var yesno: [uint8][] := {": no\n", ": yes\n"};
var test: [uint8][] := {
"The quick brown fox jumps over the lazy dog.",
"The five boxing wizards dump quickly."
};
var i: @indexof test := 0;
while i < @sizeof test loop
print(test[i]);
print(yesno[pangram(test[i])]);
i := i + 1;
end loop;

View file

@ -0,0 +1,6 @@
def pangram?(sentence)
('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.")

View file

@ -0,0 +1,19 @@
bool isPangram(in string text) pure nothrow @safe @nogc {
uint bitset;
foreach (immutable c; text) {
if (c >= 'a' && c <= 'z')
bitset |= (1u << (c - 'a'));
else if (c >= 'A' && c <= 'Z')
bitset |= (1u << (c - 'A'));
}
return bitset == 0b11_11111111_11111111_11111111;
}
void main() {
assert("the quick brown fox jumps over the lazy dog".isPangram);
assert(!"ABCDEFGHIJKLMNOPQSTUVWXYZ".isPangram);
assert(!"ABCDEFGHIJKL.NOPQRSTUVWXYZ".isPangram);
assert("ABC.D.E.FGHI*J/KL-M+NO*PQ R\nSTUVWXYZ".isPangram);
}

View file

@ -0,0 +1,22 @@
import std.string, std.traits, std.uni;
// Do not compile with -g (debug info).
enum Alphabet : dstring {
DE = "abcdefghijklmnopqrstuvwxyzßäöü",
EN = "abcdefghijklmnopqrstuvwxyz",
SV = "abcdefghijklmnopqrstuvwxyzåäö"
}
bool isPangram(S)(in S s, dstring alpha = Alphabet.EN)
pure /*nothrow*/ if (isSomeString!S) {
foreach (dchar c; alpha)
if (indexOf(s, c) == -1 && indexOf(s, std.uni.toUpper(c)) == -1)
return false;
return true;
}
void main() {
assert(isPangram("the quick brown fox jumps over the lazy dog".dup, Alphabet.EN));
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));
}

View file

@ -0,0 +1,21 @@
program PangramChecker;
{$APPTYPE CONSOLE}
uses StrUtils;
function IsPangram(const aString: string): Boolean;
var
c: char;
begin
for c := 'a' to 'z' do
if not ContainsText(aString, c) then
Exit(False);
Result := True;
end;
begin
Writeln(IsPangram('The quick brown fox jumps over the lazy dog')); // true
Writeln(IsPangram('Not a panagram')); // false
end.

View file

@ -0,0 +1,31 @@
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

View file

@ -0,0 +1,3 @@
def isPangram(sentence :String) {
return ("abcdefghijklmnopqrstuvwxyz".asSet() &! sentence.toLowerCase().asSet()).size() == 0
}

View file

@ -0,0 +1,132 @@
[Pangram checker for Rosetta Code.
EDSAC program, Initial Orders 2.]
[Outline: Make a table, one entry per 5-bit character code.
Initialize entry for each letter to 1.
When a letter is read, convert its entry to 0.]
[Subroutine to read string from the input and
store it with character codes in low 5 bits.
String is terminated by blank row of tape, which is stored.
Input: 0F holds address of string in address field (bits 1..11).
21 locations; workspace: 4F]
T 56 K
GKA3FT17@AFA18@T7@I4FA4FUFS19@G12@S20@G16@T4FA7@A2FE4@T4FEFUFP8FPD
[*************** Rosetta Code task ***************
Subroutine to test whether string is a pangram.
Input: 0F = address of string, characters in low 5 bits,
terminated by blank row of tape.
Output: 1F = (number of missing letters) - 1.
87 memory locations; workspace 4F.]
T 88 K
G K
A 3 F [make and plant link for return]
T 48 @
[Fill letter table with 1's.
The code is a bit neater if we work backwards.]
A 54 @ [index of last entry]
[3] A 51 @ [make T order for table entry]
T 6 @ [plant in code]
A 53 @ [acc := 1]
[6] T F [table entry := 1]
A 6 @ [dec address in table]
S 2 F
S 51 @ [finished table?]
E 3 @ [loop back if not]
[Set non-letters to 0, except blank row := -1]
T 4 F [clear acc]
T 66 @ [figures shift]
T 70 @ [letters shift]
T 73 @ [carriage return]
T 75 @ [space]
T 79 @ [line feed]
S 53 @ [acc := -1]
T 71 @ [blank row of tape]
[Loop to read characters from string.
Terminated by blank row of tape.
Assume acc = 0 here.]
A F [load address of string]
A 49 @ [make order to read first char]
[21] T 22 @ [plant in code]
[22] A F [char to acc]
L D [shift to address field]
A 50 @ [make A order for this char in table]
U 28 @ [plant in code]
A 52 @ [convert to T order]
T 31 @ [plant in code]
[28] A F [load table entry]
G 35 @ [jump out if it's -1, i.e. blank row]
T 4 F [clear acc]
[31] T F [table entry := 0 to flag that letter is present]
A 22 @ [inc address in input string]
A 2 F
G 21 @ [back to read next char]
[Get total of table entries, again working backwards.
The number of missing letters is (total + 1).]
[35] T 4 F [clear acc]
T 1 F [initialize total := 0]
A 54 @ [index of last entry]
[38] A 50 @ [make A order for table entry]
T 41 @ [plant in code]
A 1 F [load total so far]
[41] A F [add table entry]
T 1 F [update total]
A 41 @ [load A order]
S 2 F [dec address]
S 50 @ [finished table?]
E 38 @ [loop back if not]
T 4 F [clear acc before exit]
[48] E F
[Constants]
[49] A F [to make A order referring to input]
[50] A 55 @ [to make A order referring to table]
[51] T 55 @ [to make T order referring to table]
[52] O F [add to A order to convert to T order]
[53] P D [constant 1]
[54] P 31 F [to change address by 31]
[Table]
[55] PFPFPFPFPFPFPFPFPFPFPF
[66] PFPFPFPF [11 = figures shift]
[70] PF [15 = letters shift]
[71] PFPF [16 = blank row of tape]
[73] PFPF [18 = carriage return]
[75] PFPFPFPF [20 = space]
[79] PFPFPFPFPFPFPFPF [24 = line feed]
[Main routine to demonstrate pangram-checking subroutine]
T 200 K
G K
[Constants]
[0] P 25 @ [address for input string]
[1] N F [letter N]
[2] Y F [letter Y]
[3] K 2048 F [letter shift]
[4] @ F [carriage return]
[5] & F [line feed]
[6] K 4096 F [null char]
[Enter with acc = 0]
[7] O 3 @ [set letters shift]
[8] A @ [load address of input]
T F [pass to input subroutine in 0F]
[10] A 10 @ [call input subroutine, doesn't change 0F]
G 56 F
[12] A 12 @ [call pangram subroutine]
G 88 F
[We could print the number of missing letters,
but we'll just print 'Y' or 'N'.]
A 1 F [load (number missing) - 1]
E 18 @ [jump if not pangram]
O 2 @ [print 'Y']
G 19 @ [exit]
[18] O 1 @ [print 'N']
[19] O 4 @ [print CR, LF]
O 5 @
O 6 @ [print null to flush printer buffer]
Z F [stop]
T F [on Reset, clear acc]
E 8 @ [and test another string]
[25] [input string goes here]
E 7 Z [define entry point]
P F [acc = 0 on entry]
THE!QUICK!BROWN!FOX!JUMPS!OVER!THE!LAZY!DOG.

View file

@ -0,0 +1,11 @@
defmodule Pangram do
def checker(str) do
unused = Enum.to_list(?a..?z) -- to_char_list(String.downcase(str))
Enum.empty?(unused)
end
end
text = "The quick brown fox jumps over the lazy dog."
IO.puts "#{Pangram.checker(text)}\t#{text}"
text = (Enum.to_list(?A..?Z) -- 'Test') |> to_string
IO.puts "#{Pangram.checker(text)}\t#{text}"

View file

@ -0,0 +1,5 @@
-module(pangram).
-export([is_pangram/1]).
is_pangram(String) ->
ordsets:is_subset(lists:seq($a, $z), ordsets:from_list(string:to_lower(String))).

View file

@ -0,0 +1,13 @@
ISPANGRAM
=LAMBDA(s,
LET(
abc, CHARS(LOWER("abcdefghijklmnopqrstuvwxyz")),
AND(
LAMBDA(c,
ISNUMBER(SEARCH(c, s, 1))
)(
abc
)
)
)
)

View file

@ -0,0 +1,4 @@
CHARS
=LAMBDA(s,
MID(s, ROW(INDIRECT("1:" & LEN(s))), 1)
)

View file

@ -0,0 +1 @@
let isPangram (str: string) = (set['a'..'z'] - set(str.ToLower())).IsEmpty

View file

@ -0,0 +1,4 @@
: pangram? ( str -- ? )
[ "abcdefghijklmnopqrstuvwxyz" ] dip >lower diff length 0 = ;
"How razorback-jumping frogs can level six piqued gymnasts!" pangram? .

View file

@ -0,0 +1,10 @@
: pangram? ( addr len -- ? )
0 -rot bounds do
i c@ 32 or [char] a -
dup 0 26 within if
1 swap lshift or
else drop then
loop
1 26 lshift 1- = ;
s" The five boxing wizards jump quickly." pangram? . \ -1

View file

@ -0,0 +1,48 @@
module pangram
implicit none
private
public :: is_pangram
character (*), parameter :: lower_case = 'abcdefghijklmnopqrstuvwxyz'
character (*), parameter :: upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
contains
function to_lower_case (input) result (output)
implicit none
character (*), intent (in) :: input
character (len (input)) :: output
integer :: i
integer :: j
output = input
do i = 1, len (output)
j = index (upper_case, output (i : i))
if (j /= 0) then
output (i : i) = lower_case (j : j)
end if
end do
end function to_lower_case
function is_pangram (input) result (output)
implicit none
character (*), intent (in) :: input
character (len (input)) :: lower_case_input
logical :: output
integer :: i
lower_case_input = to_lower_case (input)
output = .true.
do i = 1, len (lower_case)
if (index (lower_case_input, lower_case (i : i)) == 0) then
output = .false.
exit
end if
end do
end function is_pangram
end module pangram

View file

@ -0,0 +1,15 @@
program test
use pangram, only: is_pangram
implicit none
character (256) :: string
string = 'This is a sentence.'
write (*, '(a)') trim (string)
write (*, '(l1)') is_pangram (string)
string = 'The five boxing wizards jumped quickly.'
write (*, '(a)') trim (string)
write (*, '(l1)') is_pangram (string)
end program test

View file

@ -0,0 +1,27 @@
' 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

View file

@ -0,0 +1,12 @@
s = "The quick brown fox jumps over the lazy dog."
println["\"$s\" is" + (isPangram[s] ? "" : " not") + " a pangram."]
isPangram[s] :=
{
charSet = toSet[charList[lc[s]]]
for c = "a" to "z"
if ! charSet.contains[c]
return false
return true
}

View file

@ -0,0 +1,44 @@
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

View file

@ -0,0 +1,37 @@
package main
import "fmt"
func main() {
for _, s := range []string{
"The quick brown fox jumps over the lazy dog.",
`Watch "Jeopardy!", Alex Trebek's fun TV quiz game.`,
"Not a pangram.",
} {
if pangram(s) {
fmt.Println("Yes:", s)
} else {
fmt.Println("No: ", s)
}
}
}
func pangram(s string) bool {
var missing uint32 = (1 << 26) - 1
for _, c := range s {
var index uint32
if 'a' <= c && c <= 'z' {
index = uint32(c - 'a')
} else if 'A' <= c && c <= 'Z' {
index = uint32(c - 'A')
} else {
continue
}
missing &^= 1 << index
if missing == 0 {
return true
}
}
return false
}

View file

@ -0,0 +1,7 @@
import Data.Char (toLower)
import Data.List ((\\))
pangram :: String -> Bool
pangram = null . (['a' .. 'z'] \\) . map toLower
main = print $ pangram "How razorback-jumping frogs can level six piqued gymnasts!"

View file

@ -0,0 +1,8 @@
PangramBrokenAt("This is a Pangram.") ! => 2 (b is missing)
PangramBrokenAt("The quick Brown Fox jumps over the Lazy Dog") ! => 0 (OK)
FUNCTION PangramBrokenAt(string)
CHARACTER string, Alfabet="abcdefghijklmnopqrstuvwxyz"
PangramBrokenAt = INDEX(Alfabet, string, 64)
! option 64: verify = 1st letter of string not in Alfabet
END

View file

@ -0,0 +1,3 @@
procedure panagram(s) #: return s if s is a panagram and fail otherwise
if (map(s) ** &lcase) === &lcase then return s
end

View file

@ -0,0 +1,11 @@
procedure main(arglist)
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

View file

@ -0,0 +1,14 @@
Sequence isPangram := method(
letters := " " repeated(26)
ia := "a" at(0)
foreach(ichar,
if(ichar isLetter,
letters atPut((ichar asLowercase) - ia, ichar)
)
)
letters contains(" " at(0)) not // true only if no " " in letters
)
"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

View file

@ -0,0 +1,5 @@
Text isPangram? = method(
letters = "abcdefghijklmnopqrstuvwxyz" chars
text = self lower chars
letters map(x, text include?(x)) reduce(&&)
)

View file

@ -0,0 +1,7 @@
iik> "The quick brown fox jumps over the lazy dog" isPangram?
"The quick brown fox jumps over the lazy dog" isPangram?
+> true
iik> "The quick brown fox jumps over the" isPangram?
"The quick brown fox jumps over the" isPangram?
+> false

View file

@ -0,0 +1,2 @@
require 'strings'
isPangram=: (a. {~ 97+i.26) */@e. tolower

View file

@ -0,0 +1,4 @@
isPangram 'The quick brown fox jumps over the lazy dog.'
1
isPangram 'The quick brown fox falls over the lazy dog.'
0

View file

@ -0,0 +1,18 @@
public class Pangram {
public static boolean isPangram(String test){
for (char a = 'A'; a <= 'Z'; a++)
if ((test.indexOf(a) < 0) && (test.indexOf((char)(a + 32)) < 0))
return false;
return true;
}
public static void main(String[] args){
System.out.println(isPangram("the quick brown fox jumps over the lazy dog"));//true
System.out.println(isPangram("the quick brown fox jumped over the lazy dog"));//false, no s
System.out.println(isPangram("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));//true
System.out.println(isPangram("ABCDEFGHIJKLMNOPQSTUVWXYZ"));//false, no r
System.out.println(isPangram("ABCDEFGHIJKL.NOPQRSTUVWXYZ"));//false, no m
System.out.println(isPangram("ABC.D.E.FGHI*J/KL-M+NO*PQ R\nSTUVWXYZ"));//true
System.out.println(isPangram(""));//false
}
}

View file

@ -0,0 +1,11 @@
function isPangram(s) {
var letters = "zqxjkvbpygfwmucldrhsnioate"
// sorted by frequency ascending (http://en.wikipedia.org/wiki/Letter_frequency)
s = s.toLowerCase().replace(/[^a-z]/g,'')
for (var i = 0; i < 26; i++)
if (s.indexOf(letters[i]) < 0) return false
return true
}
console.log(isPangram("is this a pangram")) // false
console.log(isPangram("The quick brown fox jumps over the lazy dog")) // true

View file

@ -0,0 +1,18 @@
(() => {
"use strict";
// ----------------- PANGRAM CHECKER -----------------
// isPangram :: String -> Bool
const isPangram = s =>
0 === "abcdefghijklmnopqrstuvwxyz"
.split("")
.filter(c => -1 === s.toLowerCase().indexOf(c))
.length;
// ---------------------- TEST -----------------------
return [
"is this a pangram",
"The quick brown fox jumps over the lazy dog"
].map(isPangram);
})();

View file

@ -0,0 +1,11 @@
def is_pangram:
explode
| map( if 65 <= . and . <= 90 then . + 32 # uppercase
elif 97 <= . and . <= 122 then . # lowercase
else empty
end )
| unique
| length == 26;
# Example:
"The quick brown fox jumps over the lazy dog" | is_pangram

View file

@ -0,0 +1,20 @@
function makepangramchecker(alphabet)
alphabet = Set(uppercase.(alphabet))
function ispangram(s)
lengthcheck = length(s) ≥ length(alphabet)
return lengthcheck && all(c in uppercase(s) for c in alphabet)
end
return ispangram
end
const tests = ["Pack my box with five dozen liquor jugs.",
"The quick brown fox jumps over a lazy dog.",
"The quick brown fox jumps\u2323over the lazy dog.",
"The five boxing wizards jump quickly.",
"This sentence contains A-Z but not the whole alphabet."]
is_english_pangram = makepangramchecker('a':'z')
for s in tests
println("The sentence \"", s, "\" is ", is_english_pangram(s) ? "" : "not ", "a pangram.")
end

View file

@ -0,0 +1,4 @@
lcase : _ci 97+!26
ucase : _ci 65+!26
tolower : {@[x;p;:;lcase@n@p:&26>n:ucase?/:x]}
panagram: {&/lcase _lin tolower x}

View file

@ -0,0 +1,4 @@
panagram "The quick brown fox jumps over the lazy dog"
1
panagram "Panagram test"
0

View file

@ -0,0 +1,6 @@
isPangram:0=#(`c$"a"+!26)^_:
isPangram"This is a test"
0
isPangram"The quick brown fox jumps over the lazy dog."
1

View file

@ -0,0 +1,20 @@
// version 1.0.6
fun isPangram(s: String): Boolean {
if (s.length < 26) return false
val t = s.toLowerCase()
for (c in 'a' .. 'z')
if (c !in t) return false
return true
}
fun main(args: Array<String>) {
val candidates = arrayOf(
"The quick brown fox jumps over the lazy dog",
"New job: fix Mr. Gluck's hazy TV, PDQ!",
"A very bad quack might jinx zippy fowls",
"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")
}

View file

@ -0,0 +1,41 @@
#!/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

View file

@ -0,0 +1,12 @@
'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

View file

@ -0,0 +1,10 @@
to remove.all :s :set
if empty? :s [output :set]
if word? :s [output remove.all butfirst :s remove first :s :set]
output remove.all butfirst :s remove.all first :s :set
end
to pangram? :s
output empty? remove.all :s "abcdefghijklmnopqrstuvwxyz
end
show pangram? [The five boxing wizards jump quickly.] ; true

View file

@ -0,0 +1,9 @@
require"lpeg"
S, C = lpeg.S, lpeg.C
function ispangram(s)
return #(C(S(s)^0):match"abcdefghijklmnopqrstuvwxyz") == 26
end
print(ispangram"waltz, bad nymph, for quick jigs vex")
print(ispangram"bobby")
print(ispangram"long sentence")

View file

@ -0,0 +1,12 @@
function trueFalse = isPangram(string)
%This works by histogramming the ascii character codes for lower case
%letters contained in the string (which is first converted to all
%lower case letters). Then it finds the index of the first letter that
%is not contained in the string (this is faster than using the find
%without the second parameter). If the find returns an empty array then
%the original string is a pangram, if not then it isn't.
trueFalse = isempty(find( histc(lower(string),(97:122))==0,1 ));
end

View file

@ -0,0 +1,5 @@
isPangram('The quick brown fox jumps over the lazy dog.')
ans =
1

View file

@ -0,0 +1,5 @@
function trueFalse = isPangram(string)
% X is a histogram of letters
X = sparse(abs(lower(string)),1,1,128,1);
trueFalse = full(all(X('a':'z') > 0));
end

View file

@ -0,0 +1,37 @@
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
if (flen = 0) then
false
else
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
if (flen = 0) then
false
else
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");

View file

@ -0,0 +1,7 @@
#Used built-in StringTools package
is_pangram := proc(str)
local present := StringTools:-LowerCase~(select(StringTools:-HasAlpha, StringTools:-Explode(str)));
local alphabets := {"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"};
present := convert(present, set);
return evalb(present = alphabets);
end proc;

View file

@ -0,0 +1,3 @@
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.");

View file

@ -0,0 +1 @@
pangramQ[msg_]:=Complement[CharacterRange["a", "z"], Characters[ToLowerCase[msg]]]=== {}

View file

@ -0,0 +1,5 @@
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]]]]

View file

@ -0,0 +1,4 @@
"abcdefghijklmnopqrstuvwxyz" "" split =alphabet
('alphabet dip lowercase (swap match) prepend all?) :pangram?
"The quick brown fox jumps over the lazy dog." pangram? puts

View file

@ -0,0 +1,22 @@
sentences = ["The quick brown fox jumps over the lazy dog.",
"Peter Piper picked a peck of pickled peppers.",
"Waltz job vexed quick frog nymphs."]
alphabet = "abcdefghijklmnopqrstuvwxyz"
pangram = function (toCheck)
sentence = toCheck.lower
fail = false
for c in alphabet
if sentence.indexOf(c) == null then return false
end for
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

View file

@ -0,0 +1,42 @@
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.

Some files were not shown because too many files have changed in this diff Show more