All pastes #447731 Raw Edit

Something

public text v1 · immutable
·published 2007-04-19 08:22 UTC
rendered paste body
(defun count-chars (text)
  (let ((mylist '()) (hash (make-hash-table)))
    (with-open-file (file text) (loop for char = (read-char file nil nil) while char do
				      (when (= 1 (incf (gethash char hash 0))) (push char mylist))))
    (dolist (i (sort mylist #'char<)) (format t "~a ---> ~a~%" i (gethash i hash2)))))

(defun count-chars (text)
  (let ((hash (make-hash-table)))
    (with-open-file (file text) (loop for char = (read-char file nil nil) while char do
				      (when (= 1 (incf (gethash char hash 0))))))
    (dolist (i (sort (loop for key being the hash-keys of hash collect key) #'char<))
      (format t "~a ---> ~a~%" i (gethash i hash)))))