             [proteus :refer [let-mutable]]
             [clojure.pprint :refer [pprint]]
             [clojure.string :as str]
+            [clojure.set :as set]
             [com.rpl.specter :refer [select 
                                      ALL
                                      select-first

  (cons 'some->> (interpose '((fn [arg] 
                              (when (sequential? arg) arg)))
                           args)))
(defn leave [odd-or-even-kw items]
  (map second (remove #((if (= odd-or-even-kw :odd) odd? even?) (first %1)) (map #(vector %1 %2) (range) items))))

(defn get-var-init-statements [& args]
  (let [set-statements (select (walker #(= (safe-some-> %1 first) 'set!)) args)
        vars (into (hash-set) (map second set-statements))
        var-init-statements (mapcat identity (map #(vector %1 nil) vars)) ]
    var-init-statements
  ))
(defn get-local-var-init-statements [& args]
  (let [set-statements (select (walker #(= (safe-some-> %1 first) :local)) args)
        vars (into (hash-set) (map #(nth %1 2) set-statements))
        var-init-statements (mapcat identity (map #(vector %1 nil) vars)) ]
    var-init-statements
  ))
(comment
  (let [s [[{:a 1} ['(set! a 3) :b #{'('(set! b 4))}]] ['(['(set! a 6)])]]
        walker-fn #(safe-some->> %1 (some (fn [arg] (= arg 'set!))))

                                               (first ret-val))]
                                 `(do (set! ~returned? true)
                                      (set! ~return-value ~ret-val))))
        nested-block `(~'_ ~@args)
        let-statements (transform (walker #(= "return" (safe-some-> %1 first)))
                                  process-return-stmts
                                  nested-block)
        process-returned? (fn [arg]
                            returned?
                            )
        let-statements (transform (walker #(= %1 :returned?)) 
                                  process-returned? 
                                  let-statements)
        init-statements (vec (concat [return-value nil
                                     returned? false] 
                                    global-var-init-statements)) 
        let-statements (into init-statements let-statements)
        expr `(let-mutable ~let-statements ~return-value)]
    (println "chunk-fn2:" global-var-init-statements)
    expr
    ))
