Post Reply 
Conversion: Algebraic - Polish - Reverse Polish - LISP ?
11-01-2024, 07:08 PM
Post: #4
RE: Conversion: Algebraic - Polish - Reverse Polish - LISP ?
It turned out to be easier than I expected.
Save the following program in →PN:
Code:
« OBJ→
  IF OVER
  THEN → n f
    « 1 n
      FOR i
        IF DUP TYPE 9 SAME
        THEN →PN
        END 1 →LIST n ROLLD
      NEXT
      IF n 1 >
      THEN 2 n
        START +
        NEXT
      END f SWAP +
    »
  ELSE 1 →LIST SWAP DROP
  END
»

Example

'x*(1+x*(1-x))*SIN(x)'
→PN

{ * { * x { + 1 { * x { - 1 x } } } } { SIN x } }
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Conversion: Algebraic - Polish - Reverse Polish - LISP ? - Thomas Klemm - 11-01-2024 07:08 PM



User(s) browsing this thread: 1 Guest(s)