Jump to content

Pangram checker: Difference between revisions

add RPL
(add RPL)
Line 3,266:
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}}==
1,151

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.