It seems that this Clojure function is designed to recursively transform Java…
- User
It seems that this Clojure function is designed to recursively transform Java Collections into Clojure data structures while handling various data types. What would I like is to do the same but from Kotlin collections to Clojure. Can it be re-implemented in Kotlin?
code#?(:clj (defn massage-input "This function works exactly like ClojureScript's `js->clj` except that it's made for Java and also converts Date objects to iso-8601 formatted strings, and defaults to :keywordize-keys true." ([x] (massage-input x :keywordize-keys true)) ([x & opts] (let [{:keys [keywordize-keys]} opts keyfn (if keywordize-keys keyword str) f (fn thisfn [x] (cond (seq? x) (doall (map thisfn x)) (coll? x) (into (empty x) (map thisfn x)) (instance? List x) (vec (map thisfn x)) (instance? Map x) (into {} (for [[k v] x] [(keyfn k) (thisfn v)])) (instance? Date x) (format-timestamp (.getTime x)) :else x))] (f x)))))
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.