** palendromic primes
   :DATE:     2010-07-20
Note that because Haskell is funny about what can be typed into the
interpreter, the following should be loaded with
#+begin_src haskell
  palendromic_primes = [x | x <- [1..], prime x, palendrome x]
        factors n = [x | x <- [1..floor(sqrt(fromIntegral(n)))], n `mod` x == 0]
        prime n = factors n == [1]
        primes = [x | x <- [2..], prime x]
        palendrome n = show(n) == reverse(show(n))
  palendromic_prime_distances = map (\(x,y)-> y-x) neighbors
        neighbors = (zip palendromic_primes (tail palendromic_primes))

#+name: palendromic_prime_distances
#+begin_src haskell
  take 180 (zip [1..] palendromic_prime_distances)

For high-quality png output from gnuplot, the following sequence of
graphing to a =.eps= file, and then converting to a =.png= can be
#+name: dist-graph
#+begin_src gnuplot :var data=palendromic_prime_distances :file pps.eps
  set term postscript landscape color enhanced
  set log y
  set title "distance between consecutive palendromic primes"
  plot "$data" with fs notitle

The =convert= command is part of the [[http://www.imagemagick.org/script/index.php][imagemagick]] suite.
#+begin_src sh :var input=dist-graph :results file
  convert -depth 300 -rotate 90 $input pps.png
  echo "pps.png"