(50g) Boustrophedon Transform - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (50g) Boustrophedon Transform (/thread-12653.html) (50g) Boustrophedon Transform - John Keith - 03-20-2019 07:21 PM Related to this older thread, the following program implements the boustrophedon transform for a list of integers. Details here and here. For example, given the list { 1 0 0 0 0 0 } the program will return the first 6 terms of A000111. Code: ``` \<< DUP SIZE \-> n   \<< DUP HEAD SWAP OVER 1. \->LIST 2. n     FOR k REVLIST OVER k GET :: + Scanl DUP Last NEWOB UNROT     NEXT DROP2 n \->LIST   \>> \>>``` For the inverse transform, simply replace the + sign with a - sign. The next program returns the triangle associated with the transformed sequence. For example, given the same input list above, the program will return the first 6 rows of A008280. Code: ``` \<< DUP SIZE \-> a n   \<< a 1. 1. SUB 2. n     FOR k DUP a k GET       \<< +       \>> k 2. MOD { Scanr } { Scanl } IFTE     NEXT n \->LIST   \>> \>>``` Both programs require GoferLists. RE: (50g) Boustrophedon Transform - John Keith - 08-22-2021 04:56 PM Here is a version of the boustrophedon transform program for the HP48G/GX. As above, replacing the OVER + with OVER - will make the program return the inverse boustrophedon transform of the list. Code: ``` \<< DUP SIZE \-> n   \<< DUP HEAD SWAP OVER 1 \->LIST 2 n     FOR k REVLIST OVER k GET SWAP 1       \<< OVER +       \>> DOLIST + DUP k GET NEWOB ROT ROT     NEXT DROP2 n \->LIST   \>> \>>``` Also, the HP 50g program in the first post has been replaced with a shorter version.