Ooh! Pictures!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{--

Not the most efficient approach :(, but ... a solution to http://lpaste.net/107702

 --}

import Data.Stream                     -- http://lpaste.net/107665
import Control.Comonad                 -- http://lpaste.net/107661
import Control.Arrow

primes :: Stream Integer
primes = filterS (\p -> all (\q -> p `mod` q > 0)
                            (takeWhileS (\r -> r < p) primesish))
                 primesish

primeNumberTheorem :: Stream (Integer, Int)
primeNumberTheorem = p' 10
   where p' n = (n, length (takeWhileS (< succ n) primes)) :< p' (n * 10)

{-- This gives us the stream (eventually):

*Analytics.Theory.Number> primeNumberTheorem 
Stream{ (10,4) :< (100,25) :< (1000,168) :< (10000,1229) :< (100000,9592) :< ... }

... which is 'kinda' like the stream:

*Analytics.Theory.Number> let stream = (10, 10 / log 10) 
             :< (stream =>> ((10*) &&& (\x -> 10 * x / log (10 *x))) . fst . extract)
*Analytics.Theory.Number> stream
Stream{ (10.0,4.3429448190325175) :< (100.0,21.71472409516259) 
         :< (1000.0,144.76482730108395) :< (10000.0,1085.7362047581294) 
         :< (100000.0,8685.889638065037) :< ... }

(maybe n / ln n already excludes outside the subranges?)

... AAAANNNNDDDD there's a pretty picture on the tweet.

 --}
13:42: Warning: Avoid lambda
Found:
\ r -> r < p
Why not:
(< p)