Python to RPN converter
|
06-28-2018, 08:04 PM
Post: #38
|
|||
|
|||
RE: Python to RPN converter
While the syntax of hy is similar to Clojure we can still use a while-loop and mutate local variables.
This makes the translation from Python straight forward. We can even break out of a loop. I've translated a few of the other examples: Celsius to Fahrenheit Code: (defn fahrenheit [celsius] Quadratic Equation Code: (defn qe [a b c] Greatest Common Divisor Code: (defn gcd [a b] Factors of a Number Code: (defn factor [n] Circumference of an Ellipse Code: (defn ellipse [a b] It appears that print is handled as a function in hy. Thus I had to extend the compiler a bit. Otherwise translating the factor function would lead to errors. It is mapped to AVIEW: Code: function = { |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)