Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,21 @@
(use-modules (ice-9 format))
(define (char-freq port table)
(if
(eof-object? (peek-char port))
table
(char-freq port (add-char (read-char port) table))))
(define (add-char char table)
(cond
((null? table) (list (list char 1)))
((eq? (caar table) char) (cons (list char (+ (cadar table) 1)) (cdr table)))
(#t (cons (car table) (add-char char (cdr table))))))
(define (format-table table)
(for-each (lambda (t) (format #t "~10s~10d~%" (car t) (cadr t))) table))
(define (print-freq filename)
(format-table (char-freq (open-input-file filename) '())))
(print-freq "letter-frequency.scm")

View file

@ -0,0 +1,8 @@
(with-input-from-string "foobar"
(lambda ()
(port-fold (lambda (x s)
(alist-update x
(add1 (alist-ref x s eq? 0))
s))
'()
read-char)))