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
This commit is contained in:
2026-05-11 10:08:46 +03:00
parent 4afef5a264
commit 456636700c
6 changed files with 169 additions and 43 deletions
+13
View File
@@ -0,0 +1,13 @@
; FizzBuzz — classic programming challenge
; Tests: cond, mod, map, range, str, println
(defn fizzbuzz [n]
(cond
(= (mod n 15) 0) "FizzBuzz"
(= (mod n 3) 0) "Fizz"
(= (mod n 5) 0) "Buzz"
:else (str n)))
(println "=== FizzBuzz 1-30 ===")
(doseq [i (range 1 31)]
(println (fizzbuzz i)))
+17
View File
@@ -0,0 +1,17 @@
; 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)))))