Sample LA: Dictionaries

Design and write functions that utilize dictionaries.

Suppose counts is a dictionary that whose keys are words and whose values are integers that represent how many times the word appears in a text. Write a procedure, (frequent-words counts n), that makes a list of all words that appear at least n times.

(define word-counts
  (list (pair "sentient" 20)
        (pair "triskaidecaphobia" 2)
        (pair "malicious" 20)
        (pair "hello" 1021)
        (pair "optimism" -1)
        (pair "um" 82531)
        (pair "fail" 0)))
; list out words with a frequency of at least 100
(frequent-words word-counts 100)
> (list "um" "hello")

; list out words with a frequency of at least 100000
(frequent-words word-counts 100000)
> (list)