Post Reply 
Conversion: Algebraic - Polish - Reverse Polish - LISP ?
11-02-2024, 12:57 PM (This post was last modified: 11-02-2024 12:59 PM by John Keith.)
Post: #6
RE: Conversion: Algebraic - Polish - Reverse Polish - LISP ?
(11-01-2024 07:08 PM)Thomas Klemm Wrote:  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
»

Very neat program! One question: Is there a reason that the first loop is a FOR loop rather than a START loop? I don't see a reference to i anywhere in the program.
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 ? - John Keith - 11-02-2024 12:57 PM



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