RosettaCodeData/Task/Letter-frequency/Bracmat/letter-frequency-1.bracmat
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

17 lines
612 B
Text

(lc=
counts c
. fil$(!arg,r) {open file for reading}
& 0:?counts
& whl
' ( fil$:?c {read a byte}
& ( !c:(~<A:~>Z|~<a:~>z)
| 0
)
+ !counts
: ?counts {simply add any found letter to the sum}
)
& fil$(,SET,-1) {close the file by seeking to impossible file position.}
| !counts {return the sum}
);
lc$"valid.bra" {example: count letters in Bracmat's validation suite.}