Jump to content

Letter frequency: Difference between revisions

Added Quackery.
(Added Quackery.)
Line 4,145:
 
Again eliminating all fussing with the details of converting letters into list indices.
 
=={{header|Quackery}}==
 
<lang Quackery> [ [] 26 times [ 0 join ] ] is makecountnest ( --> [ )
 
[ char A char Z 1+ within ] is ischar ( c --> b )
 
[ char A -
2dup peek 1+ unrot poke ] is tallychar ( [ c --> [ )
 
[ makecountnest swap
witheach
[ upper dup ischar iff
tallychar
else drop ] ] is countchars ( $ --> [ )
 
[ say "Letter count:" cr
witheach
[ say " "
i^ char A + emit
say ":" echo
cr ] ] is echocount ( [ --> )
 
[ sharefile 0 = if
[ $ " not found."
join fail ]
countchars
echocount ] is fileletters ( $ --> )</lang>
 
'''Testing in Quackery shell:'''
 
<pre>O> $ "quackery.py" fileletters ( i.e. the Quackery source file )
...
Letter count:
A:1324
B:433
C:819
D:897
E:2336
F:647
G:237
H:402
I:1393
J:82
K:359
L:683
M:537
N:1330
O:1171
P:835
Q:93
R:1393
S:1547
T:1769
U:697
V:105
W:257
X:281
Y:145
Z:34
 
Stack empty.
 
/O> $ "nosuchfile.txt" fileletters
...
 
Problem: nosuchfile.txt not found.
Quackery Stack:
Return stack: {[...] 0} {quackery 1} {[...] 11} {shell 5} {quackery 1} {[...] 1} {fileletters 4}</pre>
 
 
 
 
=={{header|Quick Basic/QBASIC/PDS 7.1/VB-DOS}}==
1,493

edits

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