Data update
This commit is contained in:
parent
0df55f9f24
commit
aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions
14
Task/Letter-frequency/Emacs-Lisp/letter-frequency.l
Normal file
14
Task/Letter-frequency/Emacs-Lisp/letter-frequency.l
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
(defun tally-letter-frequency-in-file ()
|
||||
(let ((alphabet "abcdefghijklmnopqrstuvwxyz")
|
||||
(current-letter)
|
||||
(count)
|
||||
(case-fold-search t)) ; ignores case
|
||||
(find-file "~/Documents/Elisp/MobyDick.txt") ; identify file to work with
|
||||
(while (>= (length alphabet) 1) ; as long as there is at least 1 letter left in alphabet
|
||||
(beginning-of-buffer)
|
||||
(setq current-letter (substring alphabet 0 1)) ; set current-letter to first letter of alphabet
|
||||
(setq count (how-many current-letter)) ; count how many of this letter in file
|
||||
(end-of-buffer)
|
||||
(insert (format "\n%s%s - %7d" current-letter (upcase current-letter) count))
|
||||
(setq alphabet (substring alphabet 1 nil))) ; remove first letter from alphabet
|
||||
(insert "\n")))
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
import Data.List (group,sort)
|
||||
import Control.Arrow ((&&&))
|
||||
main = interact (show . map (head &&& length) . group . sort)
|
||||
import Data.List (group, sort)
|
||||
|
||||
main :: IO ()
|
||||
main = interact (show . fmap ((,) . head <*> length) . group . sort
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
val .countLetters = f(.s) {
|
||||
val .countLetters = fn(.s) {
|
||||
for[=h{}] .s2 in split(replace(.s, RE/\P{L}/)) {
|
||||
_for[.s2; 0] += 1
|
||||
}
|
||||
}
|
||||
|
||||
val .counts = .countLetters(readfile "./fuzz.txt")
|
||||
writeln join "\n", map f(.k) $"\.k;: \.counts[.k];", keys .counts
|
||||
writeln join "\n", map fn(.k) $"\.k;: \.counts[.k];", keys .counts
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue