11-24-2019, 10:12 PM
This program computes the WEIGH transform of a sequence of integers. Some information here.
The program requires the ListExt Library and must be run in exact mode.
The program requires the ListExt Library and must be run in exact mode.
Code:
\<< 1 OVER HEAD 2. \->LIST OVER SIZE R\->I \-> a n
\<< DUP HEAD SWAP 2 n
FOR k k DIVIS DUP2 LPICK OVER * SWAP REV 1.
\<< I\->R 2. MOD { 1 } { -1 } IFTE
\>> DOLIST * LSUM SWAP
NEXT DROP n \->LIST a 2 n
FOR j OVER 1 j SUB OVER REV * LSUM j / +
NEXT NIP
\>>
\>>