Conversion: Algebraic - Polish - Reverse Polish - LISP ?
|
11-01-2024, 06:45 PM
Post: #3
|
|||
|
|||
RE: Conversion: Algebraic - Polish - Reverse Polish - LISP ?
Hi, Martin Hepperle
I am unfamiliar with LISP macros, but I made calc macro for Chez scheme. It by-passed Scheme built-in syntax extensions, work directly with syntax-objects, thus compile very fast. Of course, same code work with quoted objects too. Here, I strip out Scheme syntax-object manipulations, to produce equivalent function '$' Code: (define ^ expt) scheme> ($ '(x (1 + x (1 - x)) (@ sin x))) (* (* x (+ 1 (* x (- 1 x)))) (sin x)) (12-23-2022 02:59 AM)Albert Chan Wrote: And, for Mach number test. Spaces are needed to separate the tokens. scheme> (def v ($ '(5 *(((((1 + .2 *(350 / 661.5)^ 2)^ 3.5 - 1)* (1 - 6.875E-6 * 25500)^ - 5.2656)+ 1)^ .286 - 1)))) scheme> (sqrt (eval v)) 0.8357245351752515 Note: this is not the right way to evaluate complicated expression. It should have broken up. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)