clj-python / libpython-clj

Python bindings for Clojure
Eclipse Public License 2.0
1.05k stars 68 forks source link

Data transformation pipelines? #255

Closed jjtolton closed 8 months ago

jjtolton commented 8 months ago

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

:neutral_face:

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.

jjtolton commented 8 months ago

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.