RosettaCodeData/Task/Letter-frequency/EchoLisp/letter-frequency-1.echolisp
2016-12-05 23:44:36 +01:00

11 lines
426 B
Text

;; bump count when letter added
(define (hash-counter hash key )
;; (set! key (string-downcase key)) - if ignore case wanted
(putprop hash (1+ (or (getprop hash key) 0 )) key))
;; apply to exploded string
;; and sort result
(define (hash-compare a b) ( < (first a) (first b)))
(define (count-letters hash string)
(map (curry hash-counter hash) (string->list string))
(list-sort hash-compare (symbol-plist hash)))