The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
(50g) Boustrophedon Transform
03-20-2019, 07:21 PM (This post was last modified: 08-22-2021 04:47 PM by John Keith.)
Post: #1
(50g) Boustrophedon Transform
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.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(50g) Boustrophedon Transform - John Keith - 03-20-2019 07:21 PM



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