clj-python/libpython-clj

Data transformation pipelines?

jjtolton opened this issue · 1 comments

Consider adding some arbitrary data transformation abilities to py...

Imagine:

(defn times-11 [n]
  (py.. (python/list [1 2 3])
        __len__
        (as-> $ (+ 2 $))
        (some-> vector (get 3) (+ 3))
        (cond->
         nil?
          (conj 1))
        (-> first)
        (as-> $ (python/list [1 2 3 $ 4]))
        (->> (repeat n)
             (transduce
              (map (fn [args]
                     (apply + args)))
              (completing +)
              0))))

(- (times-11 4) 2) ;;=> 42

😐

Aside from generating unreadable code, would be a great time saver in some exploratory development. Additionally, would allow for casting back and forth between Clojure and python a little easier.

After some consideration I decided I'm not sure how this fits into the libpython-clj core, but might be better as a tool in the libpython-clj ecosystem.