Files
dimgigov 456636700c feat: 80/80 unit tests, real-world examples (FizzBuzz, WordFreq)
- Emitter: def registry (definedGlobals) for symbol emit distinction
- Emitter: cond emits return statements
- Emitter: reduce wraps named functions in closure adapter
- Emitter: clojure.string/* function mappings (split, lower-case, etc.)
- Emitter: statement detection for echo cljRepr wrapping
- Runtime: cljGet supports default value (3 args)
- Runtime: cljStrSplit supports regex patterns via re module
- Examples: fizzbuzz.clj and wordfreq.clj both compile and run correctly
- Tests: emit symbol / emit mangled symbol now pass (80/80)
- Compliance: 233/233 (100%) maintained
2026-05-11 10:08:46 +03:00

18 lines
543 B
Clojure

; Word Frequency Counter — data processing example
; Tests: reduce, assoc, get, keys, sort, str, println
(defn add-word [acc word]
(let [w (clojure.string/lower-case word)]
(assoc acc w (inc (get acc w 0)))))
(defn word-freq [text]
(let [words (clojure.string/split text #"\s+")]
(reduce add-word {} words)))
(def sample "the quick brown fox jumps over the lazy dog the fox")
(println "=== Word Frequency ===")
(let [freq (word-freq sample)]
(doseq [word (sort (keys freq))]
(println (str word ": " (get freq word)))))