(49G) Palindrome Locator

+- HP Forums (http://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (49G) Palindrome Locator (/thread-9991.html)



(49G) Palindrome Locator - Gerald H - 01-21-2018 10:42 AM

Given positive integer palindromic input N the programme will return the position of the palindrome in the series of palindromes ordered naturally.

For info on palindromes see

https://oeis.org/A002113

Size: 107.5

CkSum: # C723h

Code:
::
  CK1&Dispatch
  # FF
  ::
    DUP
    FPTR2 ^Z>S
    DUPDUP
    '
    xSREV
    EvalNoCK
    EQUAL
    NcaseSIZEERR
    SWAPDROP
    DUPLEN$
    BINT2
    #/
    OVER
    #0=ITE
    ::
      SUB$
      CHR_1
      >H$
    ;
    ::
      #1+
      SUB$
      DUP
      CDR$
      SWAPONE
      SUB$1#
      BINT48
      #1--
      #>$
      SWAP&$
    ;
    FPTR2 ^S>Z
  ;
;