hpal.hs 204 B

123456789101112131415
  1. -- Slide 16
  2. r n = rconcat n 0
  3. rconcat inv outv =
  4. if inv == 0
  5. then outv
  6. else rconcat (div inv 10) (outv * 10 + mod inv 10)
  7. ispal n = r n == n
  8. hpal n =
  9. if ispal n
  10. then 0
  11. else 1 + hpal (n + r n)