Anonymous user
Pangram checker: Difference between revisions
Added uBasic/4tH version
(→{{header|K}}: ngn/k) |
imported>Thebeez (Added uBasic/4tH version) |
||
(6 intermediate revisions by 5 users not shown) | |||
Line 913:
<pre>NOT A PANGRAM</pre>
==={{header|uBasic/4tH}}===
<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$)
Line 1,655 ⟶ 1,685:
<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 2,068 ⟶ 2,132:
=={{header|Fōrmulæ}}==
{{FormulaeEntry|page=https://formulae.org/?script=examples/Pangram_checker}}
'''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}}==
Line 2,157 ⟶ 2,231:
write(" a panagram.")
end</syntaxhighlight>
=={{Header|Insitux}}==
<syntaxhighlight lang="insitux">
(function pangram? sentence
(let prepped (-> sentence lower-case to-vec))
(all? prepped (map char-code (range 97 123))))
(pangram? "The five boxing wizards jump quickly.")
</syntaxhighlight>
=={{header|Io}}==
Line 3,270 ⟶ 3,354:
return pan
</syntaxhighlight>
=={{header|RPL}}==
====Structurally programmed====
{| class="wikitable" ≪
! RPL code
! Comment
|-
|
≪
# 0h SWAP 1 OVER SIZE '''FOR''' j
DUP j DUP SUB NUM
'''IF''' DUP 97 ≥ OVER 122 ≤ AND '''THEN''' 32 - '''END'''
'''IF''' DUP 65 ≥ OVER 90 ≤ AND '''THEN'''
2 SWAP 65 - ^ R→B ROT OR SWAP
'''ELSE''' DROP '''END'''
'''NEXT''' DROP # 3FFFFFFh ==
≫ ‘<span style="color:blue">PANG?</span>’ STO
|
<span style="color:blue">PANG?</span> ''( "sentence" → boolean ) ''
alpha = 0; loop for j = 1 to length(sentence)
c = ascii(sentence[j])
if c lowercase then make it uppercase
if c in ("A".."Z") then
alpha &= 2^(c-65)
end loop
return alpha & 3FFFFFFh
|}
====Idiomatically optimized for HP-28S====
{| class="wikitable" ≪
! RPL code
! Comment
|-
|
≪
# 7FFFFFEh RCLF OVER NOT AND STOF SWAP
1 OVER SIZE '''FOR''' j
DUP j DUP SUB NUM
DUP 97 ≥ 95 63 IFTE - 1 MAX 28 MIN SF
'''NEXT''' DROP RCLF OVER AND ==
≫ ‘<span style="color:blue">PANG?</span>’ STO
|
<span style="color:blue">PANG?</span> ''( "sentence" → boolean ) ''
clear flags 1 to 28
loop for j = 1 to length(sentence)
c = ascii(sentence[j])
reduce c to a value between 1 and 28 and set related flag
return 1 if all flags between 2 and 27 are set
|}
To run on more recent models, the following sequence in line 2
RCLF OVER NOT AND STOF
must be replaced by
RCLF DUP 2 GET 3 PICK NOT AND 2 SWAP PUT STOF
and <code>RCLF</code> in the last line by <code>RCLF 2 GET</code>.
"The quick brown fox jumps over the lazy dog" <span style="color:blue">PANG?</span>
"The quick brown fox jumped over the lazy dog" <span style="color:blue">PANG?</span>
{{out}}
<pre>
2: 1
1: 0
</pre>
=={{header|Ruby}}==
Line 3,683 ⟶ 3,829:
=={{header|Wren}}==
{{libheader|Wren-str}}
<syntaxhighlight lang="
var isPangram = Fn.new { |s|
|