Closed DurhamSmith closed 3 years ago
If you mean converting from lisp-code to equivalent python script, nope; the closest I know of is cl4py that one can use to write a python script which can use lisp.
Thanks, sorry for my ambiguous first message. What I am looking for is something that can take code, like the following:
(ql:quickload :py4cl)
(py4cl:import-module "numpy" :as "np")
(py4cl:import-module "scipy.integrate" :as "integrate")
;; Integrate some ODEs
(defparameter *data*
(integrate:odeint
(lambda (y time)
(vector (aref y 1) ; dy[0]/dt = y[1]
(- (aref y 0)))) ; dy[1]/dt = -y[0]
#(1.0 0.0) ; Initial state
(np:linspace 0.0 (* 2 pi) 20))) ; Vector of times
; (array-dimensions *data*) => (20 2)
;; Make a plot, save and show it in a window
(py4cl:import-module "matplotlib.pyplot" :as "plt")
(plt:plot *data*)
(plt:xlabel "Time")
(plt:savefig "result.pdf")
(plt:show)
and turn it into a pure python script.
I don't know of anything that can do that. And, due to the semantic/power differences, it'd also be difficult to do that in general. I can imagine some subset of lisp being transpiled to python, perhaps using hylang as an intermediate; but don't know of anything that is available today.
Ok, thanks for the prompt response!
Hello, I am wondering if there is any way to generate .py files from lisp code that that implements the desired python script using py4cl.