HP Forums

Full Version: (49g 50g) WEIGH Transform
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.

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
  \>>
\>>
Program in first post has been replaced with a new version which is substantially faster. It now runs at a speed comparable to other transforms. Please delete and replace the older version.
Reference URL's