diff options
author | bd <bdunahu@operationnull.com> | 2024-05-24 18:21:35 -0600 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2024-05-24 18:21:35 -0600 |
commit | 6b40eb033d9c0bda4006f23426c34ef8fda4a0d5 (patch) | |
tree | f0efe82e05d27b4056be76baca258880a0698c98 /spellcheck/hasher | |
parent | 5df534c4e3893a9f7a4f528746eca98d7a012736 (diff) |
Add partial "mutate" implementation, failing tests
Diffstat (limited to 'spellcheck/hasher')
-rw-r--r-- | spellcheck/hasher/dictionary.scm | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/spellcheck/hasher/dictionary.scm b/spellcheck/hasher/dictionary.scm deleted file mode 100644 index 10ec3b8..0000000 --- a/spellcheck/hasher/dictionary.scm +++ /dev/null @@ -1,37 +0,0 @@ -(define-module (hasher dictionary) - #:export (create-dictionary - dict-occur-ref - dict-keys-ref - dict-values-ref)) - -(define (create-dictionary lst) - (dictionary-helper (make-hash-table) lst)) - -(define (dictionary-helper dict rest) - "Recursively adds words to DICT." - (if (null? rest) - dict - (begin - (dict-inc-word dict (car rest)) - (dictionary-helper dict (cdr rest))))) - -(define (dict-inc-word dict e) - "Inserts word E into the DICT, using E -as a key and the running total of occurances -as the value." - (hashq-set! - dict e (1+ (dict-occur-ref dict e)))) - -(define (dict-occur-ref dict e) - "A wrapper for hashq-ref. Returns '0' if an element -is not present, rather than '#f'." - (let ((occur (hashq-ref dict e))) - (if occur occur 0))) - -(define (dict-keys-ref dict) - "Returns a list of all words in the dictionary." - (map car (hash-map->list cons dict))) - -(define (dict-values-ref dict) - "Sums up the total number of occurances for all words." - (apply + (map cdr (hash-map->list cons dict)))) |