##// END OF EJS Templates
coal/paper/spartan: remove extra line break in annotate view
Martin Geisler -
r8504:e35d844f default
parent child Browse files
Show More
@@ -1,79 +1,77 b''
1 {header}
1 {header}
2 <title>{repo|escape}: {file|escape} annotate</title>
2 <title>{repo|escape}: {file|escape} annotate</title>
3 </head>
3 </head>
4 <body>
4 <body>
5
5
6 <div class="container">
6 <div class="container">
7 <div class="menu">
7 <div class="menu">
8 <div class="logo">
8 <div class="logo">
9 <a href="http://www.selenic.com/mercurial/">
9 <a href="http://www.selenic.com/mercurial/">
10 <img src="{staticurl}hglogo.png" alt="mercurial" /></a>
10 <img src="{staticurl}hglogo.png" alt="mercurial" /></a>
11 </div>
11 </div>
12 <ul>
12 <ul>
13 <li><a href="{url}shortlog/{node|short}{sessionvars%urlparameter}">log</a></li>
13 <li><a href="{url}shortlog/{node|short}{sessionvars%urlparameter}">log</a></li>
14 <li><a href="{url}graph/{node|short}{sessionvars%urlparameter}">graph</a></li>
14 <li><a href="{url}graph/{node|short}{sessionvars%urlparameter}">graph</a></li>
15 <li><a href="{url}tags{sessionvars%urlparameter}">tags</a></li>
15 <li><a href="{url}tags{sessionvars%urlparameter}">tags</a></li>
16 <li><a href="{url}branches{sessionvars%urlparameter}">branches</a></li>
16 <li><a href="{url}branches{sessionvars%urlparameter}">branches</a></li>
17 </ul>
17 </ul>
18
18
19 <ul>
19 <ul>
20 <li><a href="{url}rev/{node|short}{sessionvars%urlparameter}">changeset</a></li>
20 <li><a href="{url}rev/{node|short}{sessionvars%urlparameter}">changeset</a></li>
21 <li><a href="{url}file/{node|short}{path|urlescape}{sessionvars%urlparameter}">browse</a></li>
21 <li><a href="{url}file/{node|short}{path|urlescape}{sessionvars%urlparameter}">browse</a></li>
22 </ul>
22 </ul>
23 <ul>
23 <ul>
24 <li><a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">file</a></li>
24 <li><a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">file</a></li>
25 <li><a href="{url}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">diff</a></li>
25 <li><a href="{url}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">diff</a></li>
26 <li class="active">annotate</li>
26 <li class="active">annotate</li>
27 <li><a href="{url}log/{node|short}/{file|urlescape}{sessionvars%urlparameter}">file log</a></li>
27 <li><a href="{url}log/{node|short}/{file|urlescape}{sessionvars%urlparameter}">file log</a></li>
28 <li><a href="{url}raw-annotate/{node|short}/{file|urlescape}">raw</a></li>
28 <li><a href="{url}raw-annotate/{node|short}/{file|urlescape}">raw</a></li>
29 </ul>
29 </ul>
30 </div>
30 </div>
31
31
32 <div class="main">
32 <div class="main">
33 <h2><a href="{url}{sessionvars%urlparameter}">{repo|escape}</a></h2>
33 <h2><a href="{url}{sessionvars%urlparameter}">{repo|escape}</a></h2>
34 <h3>annotate {file|escape} @ {rev}:{node|short}</h3>
34 <h3>annotate {file|escape} @ {rev}:{node|short}</h3>
35
35
36 <form class="search" action="{url}log">
36 <form class="search" action="{url}log">
37 {sessionvars%hiddenformentry}
37 {sessionvars%hiddenformentry}
38 <p><input name="rev" id="search1" type="text" size="30" /></p>
38 <p><input name="rev" id="search1" type="text" size="30" /></p>
39 <div id="hint">find changesets by author, revision,
39 <div id="hint">find changesets by author, revision,
40 files, or words in the commit message</div>
40 files, or words in the commit message</div>
41 </form>
41 </form>
42
42
43 <div class="description">{desc|strip|escape|addbreaks|nonempty}</div>
43 <div class="description">{desc|strip|escape|addbreaks|nonempty}</div>
44
44
45 <table id="changesetEntry">
45 <table id="changesetEntry">
46 <tr>
46 <tr>
47 <th class="author">author</th>
47 <th class="author">author</th>
48 <td class="author">{author|obfuscate}</td>
48 <td class="author">{author|obfuscate}</td>
49 </tr>
49 </tr>
50 <tr>
50 <tr>
51 <th class="date">date</th>
51 <th class="date">date</th>
52 <td class="date">{date|date} ({date|age} ago)</td>
52 <td class="date">{date|date} ({date|age} ago)</td>
53 </tr>
53 </tr>
54 <tr>
54 <tr>
55 <th class="author">parents</th>
55 <th class="author">parents</th>
56 <td class="author">{parent%filerevparent}</td>
56 <td class="author">{parent%filerevparent}</td>
57 </tr>
57 </tr>
58 <tr>
58 <tr>
59 <th class="author">children</th>
59 <th class="author">children</th>
60 <td class="author">{child%filerevchild}</td>
60 <td class="author">{child%filerevchild}</td>
61 </tr>
61 </tr>
62 {changesettag}
62 {changesettag}
63 </table>
63 </table>
64
64
65 <br/>
66
67 <div class="overflow">
65 <div class="overflow">
68 <table class="bigtable">
66 <table class="bigtable">
69 <tr>
67 <tr>
70 <th class="annotate">rev</th>
68 <th class="annotate">rev</th>
71 <th class="line">&nbsp;&nbsp;line source</th>
69 <th class="line">&nbsp;&nbsp;line source</th>
72 </tr>
70 </tr>
73 {annotate%annotateline}
71 {annotate%annotateline}
74 </table>
72 </table>
75 </div>
73 </div>
76 </div>
74 </div>
77 </div>
75 </div>
78
76
79 {footer}
77 {footer}
@@ -1,50 +1,48 b''
1 {header}
1 {header}
2 <title>{repo|escape}: {file|escape} annotate</title>
2 <title>{repo|escape}: {file|escape} annotate</title>
3 </head>
3 </head>
4 <body>
4 <body>
5
5
6 <div class="buttons">
6 <div class="buttons">
7 <a href="{url}log/{rev}{sessionvars%urlparameter}">changelog</a>
7 <a href="{url}log/{rev}{sessionvars%urlparameter}">changelog</a>
8 <a href="{url}shortlog/{rev}{sessionvars%urlparameter}">shortlog</a>
8 <a href="{url}shortlog/{rev}{sessionvars%urlparameter}">shortlog</a>
9 <a href="{url}graph{sessionvars%urlparameter}">graph</a>
9 <a href="{url}graph{sessionvars%urlparameter}">graph</a>
10 <a href="{url}tags{sessionvars%urlparameter}">tags</a>
10 <a href="{url}tags{sessionvars%urlparameter}">tags</a>
11 <a href="{url}branches{sessionvars%urlparameter}">branches</a>
11 <a href="{url}branches{sessionvars%urlparameter}">branches</a>
12 <a href="{url}rev/{node|short}{sessionvars%urlparameter}">changeset</a>
12 <a href="{url}rev/{node|short}{sessionvars%urlparameter}">changeset</a>
13 <a href="{url}file/{node|short}{path|urlescape}{sessionvars%urlparameter}">files</a>
13 <a href="{url}file/{node|short}{path|urlescape}{sessionvars%urlparameter}">files</a>
14 <a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">file</a>
14 <a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">file</a>
15 <a href="{url}log/{node|short}/{file|urlescape}{sessionvars%urlparameter}">revisions</a>
15 <a href="{url}log/{node|short}/{file|urlescape}{sessionvars%urlparameter}">revisions</a>
16 <a href="{url}raw-annotate/{node|short}/{file|urlescape}">raw</a>
16 <a href="{url}raw-annotate/{node|short}/{file|urlescape}">raw</a>
17 </div>
17 </div>
18
18
19 <h2>Annotate {file|escape}</h2>
19 <h2>Annotate {file|escape}</h2>
20
20
21 <table>
21 <table>
22 <tr>
22 <tr>
23 <td class="metatag">changeset {rev}:</td>
23 <td class="metatag">changeset {rev}:</td>
24 <td><a href="{url}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a></td></tr>
24 <td><a href="{url}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a></td></tr>
25 {parent%fileannotateparent}
25 {parent%fileannotateparent}
26 {child%fileannotatechild}
26 {child%fileannotatechild}
27 <tr>
27 <tr>
28 <td class="metatag">author:</td>
28 <td class="metatag">author:</td>
29 <td>{author|obfuscate}</td></tr>
29 <td>{author|obfuscate}</td></tr>
30 <tr>
30 <tr>
31 <td class="metatag">date:</td>
31 <td class="metatag">date:</td>
32 <td>{date|date} ({date|age} ago)</td>
32 <td>{date|date} ({date|age} ago)</td>
33 </tr>
33 </tr>
34 <tr>
34 <tr>
35 <td class="metatag">permissions:</td>
35 <td class="metatag">permissions:</td>
36 <td>{permissions|permissions}</td>
36 <td>{permissions|permissions}</td>
37 </tr>
37 </tr>
38 <tr>
38 <tr>
39 <td class="metatag">description:</td>
39 <td class="metatag">description:</td>
40 <td>{desc|strip|escape|addbreaks|nonempty}</td>
40 <td>{desc|strip|escape|addbreaks|nonempty}</td>
41 </tr>
41 </tr>
42 </table>
42 </table>
43
43
44 <br/>
45
46 <table cellspacing="0" cellpadding="0">
44 <table cellspacing="0" cellpadding="0">
47 {annotate%annotateline}
45 {annotate%annotateline}
48 </table>
46 </table>
49
47
50 {footer}
48 {footer}
@@ -1,542 +1,540 b''
1 adding isolatin.txt
1 adding isolatin.txt
2 adding primes.py
2 adding primes.py
3 % hg serve
3 % hg serve
4 % hgweb filerevision, html
4 % hgweb filerevision, html
5 200 Script output follows
5 200 Script output follows
6
6
7 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
7 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
8 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
8 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
9 <head>
9 <head>
10 <link rel="icon" href="/static/hgicon.png" type="image/png" />
10 <link rel="icon" href="/static/hgicon.png" type="image/png" />
11 <meta name="robots" content="index, nofollow" />
11 <meta name="robots" content="index, nofollow" />
12 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
12 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
13
13
14 <link rel="stylesheet" href="/highlightcss" type="text/css" />
14 <link rel="stylesheet" href="/highlightcss" type="text/css" />
15 <title>test: 3e1445510fe7 primes.py</title>
15 <title>test: 3e1445510fe7 primes.py</title>
16 </head>
16 </head>
17 <body>
17 <body>
18
18
19 <div class="container">
19 <div class="container">
20 <div class="menu">
20 <div class="menu">
21 <div class="logo">
21 <div class="logo">
22 <a href="http://www.selenic.com/mercurial/">
22 <a href="http://www.selenic.com/mercurial/">
23 <img src="/static/hglogo.png" alt="mercurial" /></a>
23 <img src="/static/hglogo.png" alt="mercurial" /></a>
24 </div>
24 </div>
25 <ul>
25 <ul>
26 <li><a href="/shortlog/3e1445510fe7">log</a></li>
26 <li><a href="/shortlog/3e1445510fe7">log</a></li>
27 <li><a href="/graph/3e1445510fe7">graph</a></li>
27 <li><a href="/graph/3e1445510fe7">graph</a></li>
28 <li><a href="/tags">tags</a></li>
28 <li><a href="/tags">tags</a></li>
29 <li><a href="/branches">branches</a></li>
29 <li><a href="/branches">branches</a></li>
30 </ul>
30 </ul>
31 <ul>
31 <ul>
32 <li><a href="/rev/3e1445510fe7">changeset</a></li>
32 <li><a href="/rev/3e1445510fe7">changeset</a></li>
33 <li><a href="/file/3e1445510fe7/">browse</a></li>
33 <li><a href="/file/3e1445510fe7/">browse</a></li>
34 </ul>
34 </ul>
35 <ul>
35 <ul>
36 <li class="active">file</li>
36 <li class="active">file</li>
37 <li><a href="/diff/3e1445510fe7/primes.py">diff</a></li>
37 <li><a href="/diff/3e1445510fe7/primes.py">diff</a></li>
38 <li><a href="/annotate/3e1445510fe7/primes.py">annotate</a></li>
38 <li><a href="/annotate/3e1445510fe7/primes.py">annotate</a></li>
39 <li><a href="/log/3e1445510fe7/primes.py">file log</a></li>
39 <li><a href="/log/3e1445510fe7/primes.py">file log</a></li>
40 <li><a href="/raw-file/3e1445510fe7/primes.py">raw</a></li>
40 <li><a href="/raw-file/3e1445510fe7/primes.py">raw</a></li>
41 </ul>
41 </ul>
42 </div>
42 </div>
43
43
44 <div class="main">
44 <div class="main">
45 <h2><a href="/">test</a></h2>
45 <h2><a href="/">test</a></h2>
46 <h3>view primes.py @ 0:3e1445510fe7</h3>
46 <h3>view primes.py @ 0:3e1445510fe7</h3>
47
47
48 <form class="search" action="/log">
48 <form class="search" action="/log">
49
49
50 <p><input name="rev" id="search1" type="text" size="30" /></p>
50 <p><input name="rev" id="search1" type="text" size="30" /></p>
51 <div id="hint">find changesets by author, revision,
51 <div id="hint">find changesets by author, revision,
52 files, or words in the commit message</div>
52 files, or words in the commit message</div>
53 </form>
53 </form>
54
54
55 <div class="description">a</div>
55 <div class="description">a</div>
56
56
57 <table id="changesetEntry">
57 <table id="changesetEntry">
58 <tr>
58 <tr>
59 <th class="author">author</th>
59 <th class="author">author</th>
60 <td class="author">&#116;&#101;&#115;&#116;</td>
60 <td class="author">&#116;&#101;&#115;&#116;</td>
61 </tr>
61 </tr>
62 <tr>
62 <tr>
63 <th class="date">date</th>
63 <th class="date">date</th>
64 <td class="date">Thu Jan 01 00:00:00 1970 +0000 (many years ago)</td>
64 <td class="date">Thu Jan 01 00:00:00 1970 +0000 (many years ago)</td>
65 </tr>
65 </tr>
66 <tr>
66 <tr>
67 <th class="author">parents</th>
67 <th class="author">parents</th>
68 <td class="author"></td>
68 <td class="author"></td>
69 </tr>
69 </tr>
70 <tr>
70 <tr>
71 <th class="author">children</th>
71 <th class="author">children</th>
72 <td class="author"></td>
72 <td class="author"></td>
73 </tr>
73 </tr>
74
74
75 </table>
75 </table>
76
76
77 <div class="overflow">
77 <div class="overflow">
78 <div class="sourcefirst"> line source</div>
78 <div class="sourcefirst"> line source</div>
79
79
80 <div class="parity0 source"><a href="#l1" id="l1"> 1</a> <span class="c">#!/usr/bin/env python</span></div>
80 <div class="parity0 source"><a href="#l1" id="l1"> 1</a> <span class="c">#!/usr/bin/env python</span></div>
81 <div class="parity1 source"><a href="#l2" id="l2"> 2</a> </div>
81 <div class="parity1 source"><a href="#l2" id="l2"> 2</a> </div>
82 <div class="parity0 source"><a href="#l3" id="l3"> 3</a> <span class="sd">&quot;&quot;&quot;Fun with generators. Corresponding Haskell implementation:</span></div>
82 <div class="parity0 source"><a href="#l3" id="l3"> 3</a> <span class="sd">&quot;&quot;&quot;Fun with generators. Corresponding Haskell implementation:</span></div>
83 <div class="parity1 source"><a href="#l4" id="l4"> 4</a> </div>
83 <div class="parity1 source"><a href="#l4" id="l4"> 4</a> </div>
84 <div class="parity0 source"><a href="#l5" id="l5"> 5</a> <span class="sd">primes = 2 : sieve [3, 5..]</span></div>
84 <div class="parity0 source"><a href="#l5" id="l5"> 5</a> <span class="sd">primes = 2 : sieve [3, 5..]</span></div>
85 <div class="parity1 source"><a href="#l6" id="l6"> 6</a> <span class="sd"> where sieve (p:ns) = p : sieve [n | n &lt;- ns, mod n p /= 0]</span></div>
85 <div class="parity1 source"><a href="#l6" id="l6"> 6</a> <span class="sd"> where sieve (p:ns) = p : sieve [n | n &lt;- ns, mod n p /= 0]</span></div>
86 <div class="parity0 source"><a href="#l7" id="l7"> 7</a> <span class="sd">&quot;&quot;&quot;</span></div>
86 <div class="parity0 source"><a href="#l7" id="l7"> 7</a> <span class="sd">&quot;&quot;&quot;</span></div>
87 <div class="parity1 source"><a href="#l8" id="l8"> 8</a> </div>
87 <div class="parity1 source"><a href="#l8" id="l8"> 8</a> </div>
88 <div class="parity0 source"><a href="#l9" id="l9"> 9</a> <span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">dropwhile</span><span class="p">,</span> <span class="n">ifilter</span><span class="p">,</span> <span class="n">islice</span><span class="p">,</span> <span class="n">count</span><span class="p">,</span> <span class="n">chain</span></div>
88 <div class="parity0 source"><a href="#l9" id="l9"> 9</a> <span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">dropwhile</span><span class="p">,</span> <span class="n">ifilter</span><span class="p">,</span> <span class="n">islice</span><span class="p">,</span> <span class="n">count</span><span class="p">,</span> <span class="n">chain</span></div>
89 <div class="parity1 source"><a href="#l10" id="l10"> 10</a> </div>
89 <div class="parity1 source"><a href="#l10" id="l10"> 10</a> </div>
90 <div class="parity0 source"><a href="#l11" id="l11"> 11</a> <span class="kn">def</span> <span class="nf">primes</span><span class="p">():</span></div>
90 <div class="parity0 source"><a href="#l11" id="l11"> 11</a> <span class="kn">def</span> <span class="nf">primes</span><span class="p">():</span></div>
91 <div class="parity1 source"><a href="#l12" id="l12"> 12</a> <span class="sd">&quot;&quot;&quot;Generate all primes.&quot;&quot;&quot;</span></div>
91 <div class="parity1 source"><a href="#l12" id="l12"> 12</a> <span class="sd">&quot;&quot;&quot;Generate all primes.&quot;&quot;&quot;</span></div>
92 <div class="parity0 source"><a href="#l13" id="l13"> 13</a> <span class="kn">def</span> <span class="nf">sieve</span><span class="p">(</span><span class="n">ns</span><span class="p">):</span></div>
92 <div class="parity0 source"><a href="#l13" id="l13"> 13</a> <span class="kn">def</span> <span class="nf">sieve</span><span class="p">(</span><span class="n">ns</span><span class="p">):</span></div>
93 <div class="parity1 source"><a href="#l14" id="l14"> 14</a> <span class="n">p</span> <span class="o">=</span> <span class="n">ns</span><span class="o">.</span><span class="n">next</span><span class="p">()</span></div>
93 <div class="parity1 source"><a href="#l14" id="l14"> 14</a> <span class="n">p</span> <span class="o">=</span> <span class="n">ns</span><span class="o">.</span><span class="n">next</span><span class="p">()</span></div>
94 <div class="parity0 source"><a href="#l15" id="l15"> 15</a> <span class="c"># It is important to yield *here* in order to stop the</span></div>
94 <div class="parity0 source"><a href="#l15" id="l15"> 15</a> <span class="c"># It is important to yield *here* in order to stop the</span></div>
95 <div class="parity1 source"><a href="#l16" id="l16"> 16</a> <span class="c"># infinite recursion.</span></div>
95 <div class="parity1 source"><a href="#l16" id="l16"> 16</a> <span class="c"># infinite recursion.</span></div>
96 <div class="parity0 source"><a href="#l17" id="l17"> 17</a> <span class="kn">yield</span> <span class="n">p</span></div>
96 <div class="parity0 source"><a href="#l17" id="l17"> 17</a> <span class="kn">yield</span> <span class="n">p</span></div>
97 <div class="parity1 source"><a href="#l18" id="l18"> 18</a> <span class="n">ns</span> <span class="o">=</span> <span class="n">ifilter</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span> <span class="o">%</span> <span class="n">p</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ns</span><span class="p">)</span></div>
97 <div class="parity1 source"><a href="#l18" id="l18"> 18</a> <span class="n">ns</span> <span class="o">=</span> <span class="n">ifilter</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span> <span class="o">%</span> <span class="n">p</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ns</span><span class="p">)</span></div>
98 <div class="parity0 source"><a href="#l19" id="l19"> 19</a> <span class="kn">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">sieve</span><span class="p">(</span><span class="n">ns</span><span class="p">):</span></div>
98 <div class="parity0 source"><a href="#l19" id="l19"> 19</a> <span class="kn">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">sieve</span><span class="p">(</span><span class="n">ns</span><span class="p">):</span></div>
99 <div class="parity1 source"><a href="#l20" id="l20"> 20</a> <span class="kn">yield</span> <span class="n">n</span></div>
99 <div class="parity1 source"><a href="#l20" id="l20"> 20</a> <span class="kn">yield</span> <span class="n">n</span></div>
100 <div class="parity0 source"><a href="#l21" id="l21"> 21</a> </div>
100 <div class="parity0 source"><a href="#l21" id="l21"> 21</a> </div>
101 <div class="parity1 source"><a href="#l22" id="l22"> 22</a> <span class="n">odds</span> <span class="o">=</span> <span class="n">ifilter</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">i</span><span class="p">:</span> <span class="n">i</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">==</span> <span class="mi">1</span><span class="p">,</span> <span class="n">count</span><span class="p">())</span></div>
101 <div class="parity1 source"><a href="#l22" id="l22"> 22</a> <span class="n">odds</span> <span class="o">=</span> <span class="n">ifilter</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">i</span><span class="p">:</span> <span class="n">i</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">==</span> <span class="mi">1</span><span class="p">,</span> <span class="n">count</span><span class="p">())</span></div>
102 <div class="parity0 source"><a href="#l23" id="l23"> 23</a> <span class="kn">return</span> <span class="n">chain</span><span class="p">([</span><span class="mi">2</span><span class="p">],</span> <span class="n">sieve</span><span class="p">(</span><span class="n">dropwhile</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="mi">3</span><span class="p">,</span> <span class="n">odds</span><span class="p">)))</span></div>
102 <div class="parity0 source"><a href="#l23" id="l23"> 23</a> <span class="kn">return</span> <span class="n">chain</span><span class="p">([</span><span class="mi">2</span><span class="p">],</span> <span class="n">sieve</span><span class="p">(</span><span class="n">dropwhile</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="mi">3</span><span class="p">,</span> <span class="n">odds</span><span class="p">)))</span></div>
103 <div class="parity1 source"><a href="#l24" id="l24"> 24</a> </div>
103 <div class="parity1 source"><a href="#l24" id="l24"> 24</a> </div>
104 <div class="parity0 source"><a href="#l25" id="l25"> 25</a> <span class="kn">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&quot;__main__&quot;</span><span class="p">:</span></div>
104 <div class="parity0 source"><a href="#l25" id="l25"> 25</a> <span class="kn">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&quot;__main__&quot;</span><span class="p">:</span></div>
105 <div class="parity1 source"><a href="#l26" id="l26"> 26</a> <span class="kn">import</span> <span class="nn">sys</span></div>
105 <div class="parity1 source"><a href="#l26" id="l26"> 26</a> <span class="kn">import</span> <span class="nn">sys</span></div>
106 <div class="parity0 source"><a href="#l27" id="l27"> 27</a> <span class="kn">try</span><span class="p">:</span></div>
106 <div class="parity0 source"><a href="#l27" id="l27"> 27</a> <span class="kn">try</span><span class="p">:</span></div>
107 <div class="parity1 source"><a href="#l28" id="l28"> 28</a> <span class="n">n</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span></div>
107 <div class="parity1 source"><a href="#l28" id="l28"> 28</a> <span class="n">n</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span></div>
108 <div class="parity0 source"><a href="#l29" id="l29"> 29</a> <span class="kn">except</span> <span class="p">(</span><span class="ne">ValueError</span><span class="p">,</span> <span class="ne">IndexError</span><span class="p">):</span></div>
108 <div class="parity0 source"><a href="#l29" id="l29"> 29</a> <span class="kn">except</span> <span class="p">(</span><span class="ne">ValueError</span><span class="p">,</span> <span class="ne">IndexError</span><span class="p">):</span></div>
109 <div class="parity1 source"><a href="#l30" id="l30"> 30</a> <span class="n">n</span> <span class="o">=</span> <span class="mi">10</span></div>
109 <div class="parity1 source"><a href="#l30" id="l30"> 30</a> <span class="n">n</span> <span class="o">=</span> <span class="mi">10</span></div>
110 <div class="parity0 source"><a href="#l31" id="l31"> 31</a> <span class="n">p</span> <span class="o">=</span> <span class="n">primes</span><span class="p">()</span></div>
110 <div class="parity0 source"><a href="#l31" id="l31"> 31</a> <span class="n">p</span> <span class="o">=</span> <span class="n">primes</span><span class="p">()</span></div>
111 <div class="parity1 source"><a href="#l32" id="l32"> 32</a> <span class="kn">print</span> <span class="s">&quot;The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">)))</span></div>
111 <div class="parity1 source"><a href="#l32" id="l32"> 32</a> <span class="kn">print</span> <span class="s">&quot;The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">)))</span></div>
112 <div class="sourcelast"></div>
112 <div class="sourcelast"></div>
113 </div>
113 </div>
114 </div>
114 </div>
115 </div>
115 </div>
116
116
117
117
118
118
119 </body>
119 </body>
120 </html>
120 </html>
121
121
122 % hgweb filerevision, html
122 % hgweb filerevision, html
123 200 Script output follows
123 200 Script output follows
124
124
125 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
125 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
126 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
126 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
127 <head>
127 <head>
128 <link rel="icon" href="/static/hgicon.png" type="image/png" />
128 <link rel="icon" href="/static/hgicon.png" type="image/png" />
129 <meta name="robots" content="index, nofollow" />
129 <meta name="robots" content="index, nofollow" />
130 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
130 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
131
131
132 <link rel="stylesheet" href="/highlightcss" type="text/css" />
132 <link rel="stylesheet" href="/highlightcss" type="text/css" />
133 <title>test: 3e1445510fe7 isolatin.txt</title>
133 <title>test: 3e1445510fe7 isolatin.txt</title>
134 </head>
134 </head>
135 <body>
135 <body>
136
136
137 <div class="container">
137 <div class="container">
138 <div class="menu">
138 <div class="menu">
139 <div class="logo">
139 <div class="logo">
140 <a href="http://www.selenic.com/mercurial/">
140 <a href="http://www.selenic.com/mercurial/">
141 <img src="/static/hglogo.png" alt="mercurial" /></a>
141 <img src="/static/hglogo.png" alt="mercurial" /></a>
142 </div>
142 </div>
143 <ul>
143 <ul>
144 <li><a href="/shortlog/3e1445510fe7">log</a></li>
144 <li><a href="/shortlog/3e1445510fe7">log</a></li>
145 <li><a href="/graph/3e1445510fe7">graph</a></li>
145 <li><a href="/graph/3e1445510fe7">graph</a></li>
146 <li><a href="/tags">tags</a></li>
146 <li><a href="/tags">tags</a></li>
147 <li><a href="/branches">branches</a></li>
147 <li><a href="/branches">branches</a></li>
148 </ul>
148 </ul>
149 <ul>
149 <ul>
150 <li><a href="/rev/3e1445510fe7">changeset</a></li>
150 <li><a href="/rev/3e1445510fe7">changeset</a></li>
151 <li><a href="/file/3e1445510fe7/">browse</a></li>
151 <li><a href="/file/3e1445510fe7/">browse</a></li>
152 </ul>
152 </ul>
153 <ul>
153 <ul>
154 <li class="active">file</li>
154 <li class="active">file</li>
155 <li><a href="/diff/3e1445510fe7/isolatin.txt">diff</a></li>
155 <li><a href="/diff/3e1445510fe7/isolatin.txt">diff</a></li>
156 <li><a href="/annotate/3e1445510fe7/isolatin.txt">annotate</a></li>
156 <li><a href="/annotate/3e1445510fe7/isolatin.txt">annotate</a></li>
157 <li><a href="/log/3e1445510fe7/isolatin.txt">file log</a></li>
157 <li><a href="/log/3e1445510fe7/isolatin.txt">file log</a></li>
158 <li><a href="/raw-file/3e1445510fe7/isolatin.txt">raw</a></li>
158 <li><a href="/raw-file/3e1445510fe7/isolatin.txt">raw</a></li>
159 </ul>
159 </ul>
160 </div>
160 </div>
161
161
162 <div class="main">
162 <div class="main">
163 <h2><a href="/">test</a></h2>
163 <h2><a href="/">test</a></h2>
164 <h3>view isolatin.txt @ 0:3e1445510fe7</h3>
164 <h3>view isolatin.txt @ 0:3e1445510fe7</h3>
165
165
166 <form class="search" action="/log">
166 <form class="search" action="/log">
167
167
168 <p><input name="rev" id="search1" type="text" size="30" /></p>
168 <p><input name="rev" id="search1" type="text" size="30" /></p>
169 <div id="hint">find changesets by author, revision,
169 <div id="hint">find changesets by author, revision,
170 files, or words in the commit message</div>
170 files, or words in the commit message</div>
171 </form>
171 </form>
172
172
173 <div class="description">a</div>
173 <div class="description">a</div>
174
174
175 <table id="changesetEntry">
175 <table id="changesetEntry">
176 <tr>
176 <tr>
177 <th class="author">author</th>
177 <th class="author">author</th>
178 <td class="author">&#116;&#101;&#115;&#116;</td>
178 <td class="author">&#116;&#101;&#115;&#116;</td>
179 </tr>
179 </tr>
180 <tr>
180 <tr>
181 <th class="date">date</th>
181 <th class="date">date</th>
182 <td class="date">Thu Jan 01 00:00:00 1970 +0000 (many years ago)</td>
182 <td class="date">Thu Jan 01 00:00:00 1970 +0000 (many years ago)</td>
183 </tr>
183 </tr>
184 <tr>
184 <tr>
185 <th class="author">parents</th>
185 <th class="author">parents</th>
186 <td class="author"></td>
186 <td class="author"></td>
187 </tr>
187 </tr>
188 <tr>
188 <tr>
189 <th class="author">children</th>
189 <th class="author">children</th>
190 <td class="author"></td>
190 <td class="author"></td>
191 </tr>
191 </tr>
192
192
193 </table>
193 </table>
194
194
195 <div class="overflow">
195 <div class="overflow">
196 <div class="sourcefirst"> line source</div>
196 <div class="sourcefirst"> line source</div>
197
197
198 <div class="parity0 source"><a href="#l1" id="l1"> 1</a> h?bsch</div>
198 <div class="parity0 source"><a href="#l1" id="l1"> 1</a> h?bsch</div>
199 <div class="sourcelast"></div>
199 <div class="sourcelast"></div>
200 </div>
200 </div>
201 </div>
201 </div>
202 </div>
202 </div>
203
203
204
204
205
205
206 </body>
206 </body>
207 </html>
207 </html>
208
208
209 % hgweb fileannotate, html
209 % hgweb fileannotate, html
210 200 Script output follows
210 200 Script output follows
211
211
212 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
212 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
213 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
213 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
214 <head>
214 <head>
215 <link rel="icon" href="/static/hgicon.png" type="image/png" />
215 <link rel="icon" href="/static/hgicon.png" type="image/png" />
216 <meta name="robots" content="index, nofollow" />
216 <meta name="robots" content="index, nofollow" />
217 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
217 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
218
218
219 <link rel="stylesheet" href="/highlightcss" type="text/css" />
219 <link rel="stylesheet" href="/highlightcss" type="text/css" />
220 <title>test: primes.py annotate</title>
220 <title>test: primes.py annotate</title>
221 </head>
221 </head>
222 <body>
222 <body>
223
223
224 <div class="container">
224 <div class="container">
225 <div class="menu">
225 <div class="menu">
226 <div class="logo">
226 <div class="logo">
227 <a href="http://www.selenic.com/mercurial/">
227 <a href="http://www.selenic.com/mercurial/">
228 <img src="/static/hglogo.png" alt="mercurial" /></a>
228 <img src="/static/hglogo.png" alt="mercurial" /></a>
229 </div>
229 </div>
230 <ul>
230 <ul>
231 <li><a href="/shortlog/3e1445510fe7">log</a></li>
231 <li><a href="/shortlog/3e1445510fe7">log</a></li>
232 <li><a href="/graph/3e1445510fe7">graph</a></li>
232 <li><a href="/graph/3e1445510fe7">graph</a></li>
233 <li><a href="/tags">tags</a></li>
233 <li><a href="/tags">tags</a></li>
234 <li><a href="/branches">branches</a></li>
234 <li><a href="/branches">branches</a></li>
235 </ul>
235 </ul>
236
236
237 <ul>
237 <ul>
238 <li><a href="/rev/3e1445510fe7">changeset</a></li>
238 <li><a href="/rev/3e1445510fe7">changeset</a></li>
239 <li><a href="/file/3e1445510fe7/">browse</a></li>
239 <li><a href="/file/3e1445510fe7/">browse</a></li>
240 </ul>
240 </ul>
241 <ul>
241 <ul>
242 <li><a href="/file/3e1445510fe7/primes.py">file</a></li>
242 <li><a href="/file/3e1445510fe7/primes.py">file</a></li>
243 <li><a href="/diff/3e1445510fe7/primes.py">diff</a></li>
243 <li><a href="/diff/3e1445510fe7/primes.py">diff</a></li>
244 <li class="active">annotate</li>
244 <li class="active">annotate</li>
245 <li><a href="/log/3e1445510fe7/primes.py">file log</a></li>
245 <li><a href="/log/3e1445510fe7/primes.py">file log</a></li>
246 <li><a href="/raw-annotate/3e1445510fe7/primes.py">raw</a></li>
246 <li><a href="/raw-annotate/3e1445510fe7/primes.py">raw</a></li>
247 </ul>
247 </ul>
248 </div>
248 </div>
249
249
250 <div class="main">
250 <div class="main">
251 <h2><a href="/">test</a></h2>
251 <h2><a href="/">test</a></h2>
252 <h3>annotate primes.py @ 0:3e1445510fe7</h3>
252 <h3>annotate primes.py @ 0:3e1445510fe7</h3>
253
253
254 <form class="search" action="/log">
254 <form class="search" action="/log">
255
255
256 <p><input name="rev" id="search1" type="text" size="30" /></p>
256 <p><input name="rev" id="search1" type="text" size="30" /></p>
257 <div id="hint">find changesets by author, revision,
257 <div id="hint">find changesets by author, revision,
258 files, or words in the commit message</div>
258 files, or words in the commit message</div>
259 </form>
259 </form>
260
260
261 <div class="description">a</div>
261 <div class="description">a</div>
262
262
263 <table id="changesetEntry">
263 <table id="changesetEntry">
264 <tr>
264 <tr>
265 <th class="author">author</th>
265 <th class="author">author</th>
266 <td class="author">&#116;&#101;&#115;&#116;</td>
266 <td class="author">&#116;&#101;&#115;&#116;</td>
267 </tr>
267 </tr>
268 <tr>
268 <tr>
269 <th class="date">date</th>
269 <th class="date">date</th>
270 <td class="date">Thu Jan 01 00:00:00 1970 +0000 (many years ago)</td>
270 <td class="date">Thu Jan 01 00:00:00 1970 +0000 (many years ago)</td>
271 </tr>
271 </tr>
272 <tr>
272 <tr>
273 <th class="author">parents</th>
273 <th class="author">parents</th>
274 <td class="author"></td>
274 <td class="author"></td>
275 </tr>
275 </tr>
276 <tr>
276 <tr>
277 <th class="author">children</th>
277 <th class="author">children</th>
278 <td class="author"></td>
278 <td class="author"></td>
279 </tr>
279 </tr>
280
280
281 </table>
281 </table>
282
282
283 <br/>
284
285 <div class="overflow">
283 <div class="overflow">
286 <table class="bigtable">
284 <table class="bigtable">
287 <tr>
285 <tr>
288 <th class="annotate">rev</th>
286 <th class="annotate">rev</th>
289 <th class="line">&nbsp;&nbsp;line source</th>
287 <th class="line">&nbsp;&nbsp;line source</th>
290 </tr>
288 </tr>
291
289
292 <tr class="parity0">
290 <tr class="parity0">
293 <td class="annotate">
291 <td class="annotate">
294 <a href="/annotate/3e1445510fe7/primes.py#1"
292 <a href="/annotate/3e1445510fe7/primes.py#1"
295 title="3e1445510fe7: a">test@0</a>
293 title="3e1445510fe7: a">test@0</a>
296 </td>
294 </td>
297 <td class="source"><a href="#l1" id="l1"> 1</a> <span class="c">#!/usr/bin/env python</span></td>
295 <td class="source"><a href="#l1" id="l1"> 1</a> <span class="c">#!/usr/bin/env python</span></td>
298 </tr>
296 </tr>
299 <tr class="parity1">
297 <tr class="parity1">
300 <td class="annotate">
298 <td class="annotate">
301 <a href="/annotate/3e1445510fe7/primes.py#2"
299 <a href="/annotate/3e1445510fe7/primes.py#2"
302 title="3e1445510fe7: a">test@0</a>
300 title="3e1445510fe7: a">test@0</a>
303 </td>
301 </td>
304 <td class="source"><a href="#l2" id="l2"> 2</a> </td>
302 <td class="source"><a href="#l2" id="l2"> 2</a> </td>
305 </tr>
303 </tr>
306 <tr class="parity0">
304 <tr class="parity0">
307 <td class="annotate">
305 <td class="annotate">
308 <a href="/annotate/3e1445510fe7/primes.py#3"
306 <a href="/annotate/3e1445510fe7/primes.py#3"
309 title="3e1445510fe7: a">test@0</a>
307 title="3e1445510fe7: a">test@0</a>
310 </td>
308 </td>
311 <td class="source"><a href="#l3" id="l3"> 3</a> <span class="sd">&quot;&quot;&quot;Fun with generators. Corresponding Haskell implementation:</span></td>
309 <td class="source"><a href="#l3" id="l3"> 3</a> <span class="sd">&quot;&quot;&quot;Fun with generators. Corresponding Haskell implementation:</span></td>
312 </tr>
310 </tr>
313 <tr class="parity1">
311 <tr class="parity1">
314 <td class="annotate">
312 <td class="annotate">
315 <a href="/annotate/3e1445510fe7/primes.py#4"
313 <a href="/annotate/3e1445510fe7/primes.py#4"
316 title="3e1445510fe7: a">test@0</a>
314 title="3e1445510fe7: a">test@0</a>
317 </td>
315 </td>
318 <td class="source"><a href="#l4" id="l4"> 4</a> </td>
316 <td class="source"><a href="#l4" id="l4"> 4</a> </td>
319 </tr>
317 </tr>
320 <tr class="parity0">
318 <tr class="parity0">
321 <td class="annotate">
319 <td class="annotate">
322 <a href="/annotate/3e1445510fe7/primes.py#5"
320 <a href="/annotate/3e1445510fe7/primes.py#5"
323 title="3e1445510fe7: a">test@0</a>
321 title="3e1445510fe7: a">test@0</a>
324 </td>
322 </td>
325 <td class="source"><a href="#l5" id="l5"> 5</a> <span class="sd">primes = 2 : sieve [3, 5..]</span></td>
323 <td class="source"><a href="#l5" id="l5"> 5</a> <span class="sd">primes = 2 : sieve [3, 5..]</span></td>
326 </tr>
324 </tr>
327 <tr class="parity1">
325 <tr class="parity1">
328 <td class="annotate">
326 <td class="annotate">
329 <a href="/annotate/3e1445510fe7/primes.py#6"
327 <a href="/annotate/3e1445510fe7/primes.py#6"
330 title="3e1445510fe7: a">test@0</a>
328 title="3e1445510fe7: a">test@0</a>
331 </td>
329 </td>
332 <td class="source"><a href="#l6" id="l6"> 6</a> <span class="sd"> where sieve (p:ns) = p : sieve [n | n &lt;- ns, mod n p /= 0]</span></td>
330 <td class="source"><a href="#l6" id="l6"> 6</a> <span class="sd"> where sieve (p:ns) = p : sieve [n | n &lt;- ns, mod n p /= 0]</span></td>
333 </tr>
331 </tr>
334 <tr class="parity0">
332 <tr class="parity0">
335 <td class="annotate">
333 <td class="annotate">
336 <a href="/annotate/3e1445510fe7/primes.py#7"
334 <a href="/annotate/3e1445510fe7/primes.py#7"
337 title="3e1445510fe7: a">test@0</a>
335 title="3e1445510fe7: a">test@0</a>
338 </td>
336 </td>
339 <td class="source"><a href="#l7" id="l7"> 7</a> <span class="sd">&quot;&quot;&quot;</span></td>
337 <td class="source"><a href="#l7" id="l7"> 7</a> <span class="sd">&quot;&quot;&quot;</span></td>
340 </tr>
338 </tr>
341 <tr class="parity1">
339 <tr class="parity1">
342 <td class="annotate">
340 <td class="annotate">
343 <a href="/annotate/3e1445510fe7/primes.py#8"
341 <a href="/annotate/3e1445510fe7/primes.py#8"
344 title="3e1445510fe7: a">test@0</a>
342 title="3e1445510fe7: a">test@0</a>
345 </td>
343 </td>
346 <td class="source"><a href="#l8" id="l8"> 8</a> </td>
344 <td class="source"><a href="#l8" id="l8"> 8</a> </td>
347 </tr>
345 </tr>
348 <tr class="parity0">
346 <tr class="parity0">
349 <td class="annotate">
347 <td class="annotate">
350 <a href="/annotate/3e1445510fe7/primes.py#9"
348 <a href="/annotate/3e1445510fe7/primes.py#9"
351 title="3e1445510fe7: a">test@0</a>
349 title="3e1445510fe7: a">test@0</a>
352 </td>
350 </td>
353 <td class="source"><a href="#l9" id="l9"> 9</a> <span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">dropwhile</span><span class="p">,</span> <span class="n">ifilter</span><span class="p">,</span> <span class="n">islice</span><span class="p">,</span> <span class="n">count</span><span class="p">,</span> <span class="n">chain</span></td>
351 <td class="source"><a href="#l9" id="l9"> 9</a> <span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">dropwhile</span><span class="p">,</span> <span class="n">ifilter</span><span class="p">,</span> <span class="n">islice</span><span class="p">,</span> <span class="n">count</span><span class="p">,</span> <span class="n">chain</span></td>
354 </tr>
352 </tr>
355 <tr class="parity1">
353 <tr class="parity1">
356 <td class="annotate">
354 <td class="annotate">
357 <a href="/annotate/3e1445510fe7/primes.py#10"
355 <a href="/annotate/3e1445510fe7/primes.py#10"
358 title="3e1445510fe7: a">test@0</a>
356 title="3e1445510fe7: a">test@0</a>
359 </td>
357 </td>
360 <td class="source"><a href="#l10" id="l10"> 10</a> </td>
358 <td class="source"><a href="#l10" id="l10"> 10</a> </td>
361 </tr>
359 </tr>
362 <tr class="parity0">
360 <tr class="parity0">
363 <td class="annotate">
361 <td class="annotate">
364 <a href="/annotate/3e1445510fe7/primes.py#11"
362 <a href="/annotate/3e1445510fe7/primes.py#11"
365 title="3e1445510fe7: a">test@0</a>
363 title="3e1445510fe7: a">test@0</a>
366 </td>
364 </td>
367 <td class="source"><a href="#l11" id="l11"> 11</a> <span class="kn">def</span> <span class="nf">primes</span><span class="p">():</span></td>
365 <td class="source"><a href="#l11" id="l11"> 11</a> <span class="kn">def</span> <span class="nf">primes</span><span class="p">():</span></td>
368 </tr>
366 </tr>
369 <tr class="parity1">
367 <tr class="parity1">
370 <td class="annotate">
368 <td class="annotate">
371 <a href="/annotate/3e1445510fe7/primes.py#12"
369 <a href="/annotate/3e1445510fe7/primes.py#12"
372 title="3e1445510fe7: a">test@0</a>
370 title="3e1445510fe7: a">test@0</a>
373 </td>
371 </td>
374 <td class="source"><a href="#l12" id="l12"> 12</a> <span class="sd">&quot;&quot;&quot;Generate all primes.&quot;&quot;&quot;</span></td>
372 <td class="source"><a href="#l12" id="l12"> 12</a> <span class="sd">&quot;&quot;&quot;Generate all primes.&quot;&quot;&quot;</span></td>
375 </tr>
373 </tr>
376 <tr class="parity0">
374 <tr class="parity0">
377 <td class="annotate">
375 <td class="annotate">
378 <a href="/annotate/3e1445510fe7/primes.py#13"
376 <a href="/annotate/3e1445510fe7/primes.py#13"
379 title="3e1445510fe7: a">test@0</a>
377 title="3e1445510fe7: a">test@0</a>
380 </td>
378 </td>
381 <td class="source"><a href="#l13" id="l13"> 13</a> <span class="kn">def</span> <span class="nf">sieve</span><span class="p">(</span><span class="n">ns</span><span class="p">):</span></td>
379 <td class="source"><a href="#l13" id="l13"> 13</a> <span class="kn">def</span> <span class="nf">sieve</span><span class="p">(</span><span class="n">ns</span><span class="p">):</span></td>
382 </tr>
380 </tr>
383 <tr class="parity1">
381 <tr class="parity1">
384 <td class="annotate">
382 <td class="annotate">
385 <a href="/annotate/3e1445510fe7/primes.py#14"
383 <a href="/annotate/3e1445510fe7/primes.py#14"
386 title="3e1445510fe7: a">test@0</a>
384 title="3e1445510fe7: a">test@0</a>
387 </td>
385 </td>
388 <td class="source"><a href="#l14" id="l14"> 14</a> <span class="n">p</span> <span class="o">=</span> <span class="n">ns</span><span class="o">.</span><span class="n">next</span><span class="p">()</span></td>
386 <td class="source"><a href="#l14" id="l14"> 14</a> <span class="n">p</span> <span class="o">=</span> <span class="n">ns</span><span class="o">.</span><span class="n">next</span><span class="p">()</span></td>
389 </tr>
387 </tr>
390 <tr class="parity0">
388 <tr class="parity0">
391 <td class="annotate">
389 <td class="annotate">
392 <a href="/annotate/3e1445510fe7/primes.py#15"
390 <a href="/annotate/3e1445510fe7/primes.py#15"
393 title="3e1445510fe7: a">test@0</a>
391 title="3e1445510fe7: a">test@0</a>
394 </td>
392 </td>
395 <td class="source"><a href="#l15" id="l15"> 15</a> <span class="c"># It is important to yield *here* in order to stop the</span></td>
393 <td class="source"><a href="#l15" id="l15"> 15</a> <span class="c"># It is important to yield *here* in order to stop the</span></td>
396 </tr>
394 </tr>
397 <tr class="parity1">
395 <tr class="parity1">
398 <td class="annotate">
396 <td class="annotate">
399 <a href="/annotate/3e1445510fe7/primes.py#16"
397 <a href="/annotate/3e1445510fe7/primes.py#16"
400 title="3e1445510fe7: a">test@0</a>
398 title="3e1445510fe7: a">test@0</a>
401 </td>
399 </td>
402 <td class="source"><a href="#l16" id="l16"> 16</a> <span class="c"># infinite recursion.</span></td>
400 <td class="source"><a href="#l16" id="l16"> 16</a> <span class="c"># infinite recursion.</span></td>
403 </tr>
401 </tr>
404 <tr class="parity0">
402 <tr class="parity0">
405 <td class="annotate">
403 <td class="annotate">
406 <a href="/annotate/3e1445510fe7/primes.py#17"
404 <a href="/annotate/3e1445510fe7/primes.py#17"
407 title="3e1445510fe7: a">test@0</a>
405 title="3e1445510fe7: a">test@0</a>
408 </td>
406 </td>
409 <td class="source"><a href="#l17" id="l17"> 17</a> <span class="kn">yield</span> <span class="n">p</span></td>
407 <td class="source"><a href="#l17" id="l17"> 17</a> <span class="kn">yield</span> <span class="n">p</span></td>
410 </tr>
408 </tr>
411 <tr class="parity1">
409 <tr class="parity1">
412 <td class="annotate">
410 <td class="annotate">
413 <a href="/annotate/3e1445510fe7/primes.py#18"
411 <a href="/annotate/3e1445510fe7/primes.py#18"
414 title="3e1445510fe7: a">test@0</a>
412 title="3e1445510fe7: a">test@0</a>
415 </td>
413 </td>
416 <td class="source"><a href="#l18" id="l18"> 18</a> <span class="n">ns</span> <span class="o">=</span> <span class="n">ifilter</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span> <span class="o">%</span> <span class="n">p</span> <span class="o">!=</span> <span class="mf">0</span><span class="p">,</span> <span class="n">ns</span><span class="p">)</span></td>
414 <td class="source"><a href="#l18" id="l18"> 18</a> <span class="n">ns</span> <span class="o">=</span> <span class="n">ifilter</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span> <span class="o">%</span> <span class="n">p</span> <span class="o">!=</span> <span class="mf">0</span><span class="p">,</span> <span class="n">ns</span><span class="p">)</span></td>
417 </tr>
415 </tr>
418 <tr class="parity0">
416 <tr class="parity0">
419 <td class="annotate">
417 <td class="annotate">
420 <a href="/annotate/3e1445510fe7/primes.py#19"
418 <a href="/annotate/3e1445510fe7/primes.py#19"
421 title="3e1445510fe7: a">test@0</a>
419 title="3e1445510fe7: a">test@0</a>
422 </td>
420 </td>
423 <td class="source"><a href="#l19" id="l19"> 19</a> <span class="kn">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">sieve</span><span class="p">(</span><span class="n">ns</span><span class="p">):</span></td>
421 <td class="source"><a href="#l19" id="l19"> 19</a> <span class="kn">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">sieve</span><span class="p">(</span><span class="n">ns</span><span class="p">):</span></td>
424 </tr>
422 </tr>
425 <tr class="parity1">
423 <tr class="parity1">
426 <td class="annotate">
424 <td class="annotate">
427 <a href="/annotate/3e1445510fe7/primes.py#20"
425 <a href="/annotate/3e1445510fe7/primes.py#20"
428 title="3e1445510fe7: a">test@0</a>
426 title="3e1445510fe7: a">test@0</a>
429 </td>
427 </td>
430 <td class="source"><a href="#l20" id="l20"> 20</a> <span class="kn">yield</span> <span class="n">n</span></td>
428 <td class="source"><a href="#l20" id="l20"> 20</a> <span class="kn">yield</span> <span class="n">n</span></td>
431 </tr>
429 </tr>
432 <tr class="parity0">
430 <tr class="parity0">
433 <td class="annotate">
431 <td class="annotate">
434 <a href="/annotate/3e1445510fe7/primes.py#21"
432 <a href="/annotate/3e1445510fe7/primes.py#21"
435 title="3e1445510fe7: a">test@0</a>
433 title="3e1445510fe7: a">test@0</a>
436 </td>
434 </td>
437 <td class="source"><a href="#l21" id="l21"> 21</a> </td>
435 <td class="source"><a href="#l21" id="l21"> 21</a> </td>
438 </tr>
436 </tr>
439 <tr class="parity1">
437 <tr class="parity1">
440 <td class="annotate">
438 <td class="annotate">
441 <a href="/annotate/3e1445510fe7/primes.py#22"
439 <a href="/annotate/3e1445510fe7/primes.py#22"
442 title="3e1445510fe7: a">test@0</a>
440 title="3e1445510fe7: a">test@0</a>
443 </td>
441 </td>
444 <td class="source"><a href="#l22" id="l22"> 22</a> <span class="n">odds</span> <span class="o">=</span> <span class="n">ifilter</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">i</span><span class="p">:</span> <span class="n">i</span> <span class="o">%</span> <span class="mf">2</span> <span class="o">==</span> <span class="mf">1</span><span class="p">,</span> <span class="n">count</span><span class="p">())</span></td>
442 <td class="source"><a href="#l22" id="l22"> 22</a> <span class="n">odds</span> <span class="o">=</span> <span class="n">ifilter</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">i</span><span class="p">:</span> <span class="n">i</span> <span class="o">%</span> <span class="mf">2</span> <span class="o">==</span> <span class="mf">1</span><span class="p">,</span> <span class="n">count</span><span class="p">())</span></td>
445 </tr>
443 </tr>
446 <tr class="parity0">
444 <tr class="parity0">
447 <td class="annotate">
445 <td class="annotate">
448 <a href="/annotate/3e1445510fe7/primes.py#23"
446 <a href="/annotate/3e1445510fe7/primes.py#23"
449 title="3e1445510fe7: a">test@0</a>
447 title="3e1445510fe7: a">test@0</a>
450 </td>
448 </td>
451 <td class="source"><a href="#l23" id="l23"> 23</a> <span class="kn">return</span> <span class="n">chain</span><span class="p">([</span><span class="mf">2</span><span class="p">],</span> <span class="n">sieve</span><span class="p">(</span><span class="n">dropwhile</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="mf">3</span><span class="p">,</span> <span class="n">odds</span><span class="p">)))</span></td>
449 <td class="source"><a href="#l23" id="l23"> 23</a> <span class="kn">return</span> <span class="n">chain</span><span class="p">([</span><span class="mf">2</span><span class="p">],</span> <span class="n">sieve</span><span class="p">(</span><span class="n">dropwhile</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="mf">3</span><span class="p">,</span> <span class="n">odds</span><span class="p">)))</span></td>
452 </tr>
450 </tr>
453 <tr class="parity1">
451 <tr class="parity1">
454 <td class="annotate">
452 <td class="annotate">
455 <a href="/annotate/3e1445510fe7/primes.py#24"
453 <a href="/annotate/3e1445510fe7/primes.py#24"
456 title="3e1445510fe7: a">test@0</a>
454 title="3e1445510fe7: a">test@0</a>
457 </td>
455 </td>
458 <td class="source"><a href="#l24" id="l24"> 24</a> </td>
456 <td class="source"><a href="#l24" id="l24"> 24</a> </td>
459 </tr>
457 </tr>
460 <tr class="parity0">
458 <tr class="parity0">
461 <td class="annotate">
459 <td class="annotate">
462 <a href="/annotate/3e1445510fe7/primes.py#25"
460 <a href="/annotate/3e1445510fe7/primes.py#25"
463 title="3e1445510fe7: a">test@0</a>
461 title="3e1445510fe7: a">test@0</a>
464 </td>
462 </td>
465 <td class="source"><a href="#l25" id="l25"> 25</a> <span class="kn">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&quot;__main__&quot;</span><span class="p">:</span></td>
463 <td class="source"><a href="#l25" id="l25"> 25</a> <span class="kn">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&quot;__main__&quot;</span><span class="p">:</span></td>
466 </tr>
464 </tr>
467 <tr class="parity1">
465 <tr class="parity1">
468 <td class="annotate">
466 <td class="annotate">
469 <a href="/annotate/3e1445510fe7/primes.py#26"
467 <a href="/annotate/3e1445510fe7/primes.py#26"
470 title="3e1445510fe7: a">test@0</a>
468 title="3e1445510fe7: a">test@0</a>
471 </td>
469 </td>
472 <td class="source"><a href="#l26" id="l26"> 26</a> <span class="kn">import</span> <span class="nn">sys</span></td>
470 <td class="source"><a href="#l26" id="l26"> 26</a> <span class="kn">import</span> <span class="nn">sys</span></td>
473 </tr>
471 </tr>
474 <tr class="parity0">
472 <tr class="parity0">
475 <td class="annotate">
473 <td class="annotate">
476 <a href="/annotate/3e1445510fe7/primes.py#27"
474 <a href="/annotate/3e1445510fe7/primes.py#27"
477 title="3e1445510fe7: a">test@0</a>
475 title="3e1445510fe7: a">test@0</a>
478 </td>
476 </td>
479 <td class="source"><a href="#l27" id="l27"> 27</a> <span class="kn">try</span><span class="p">:</span></td>
477 <td class="source"><a href="#l27" id="l27"> 27</a> <span class="kn">try</span><span class="p">:</span></td>
480 </tr>
478 </tr>
481 <tr class="parity1">
479 <tr class="parity1">
482 <td class="annotate">
480 <td class="annotate">
483 <a href="/annotate/3e1445510fe7/primes.py#28"
481 <a href="/annotate/3e1445510fe7/primes.py#28"
484 title="3e1445510fe7: a">test@0</a>
482 title="3e1445510fe7: a">test@0</a>
485 </td>
483 </td>
486 <td class="source"><a href="#l28" id="l28"> 28</a> <span class="n">n</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">1</span><span class="p">])</span></td>
484 <td class="source"><a href="#l28" id="l28"> 28</a> <span class="n">n</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">1</span><span class="p">])</span></td>
487 </tr>
485 </tr>
488 <tr class="parity0">
486 <tr class="parity0">
489 <td class="annotate">
487 <td class="annotate">
490 <a href="/annotate/3e1445510fe7/primes.py#29"
488 <a href="/annotate/3e1445510fe7/primes.py#29"
491 title="3e1445510fe7: a">test@0</a>
489 title="3e1445510fe7: a">test@0</a>
492 </td>
490 </td>
493 <td class="source"><a href="#l29" id="l29"> 29</a> <span class="kn">except</span> <span class="p">(</span><span class="ne">ValueError</span><span class="p">,</span> <span class="ne">IndexError</span><span class="p">):</span></td>
491 <td class="source"><a href="#l29" id="l29"> 29</a> <span class="kn">except</span> <span class="p">(</span><span class="ne">ValueError</span><span class="p">,</span> <span class="ne">IndexError</span><span class="p">):</span></td>
494 </tr>
492 </tr>
495 <tr class="parity1">
493 <tr class="parity1">
496 <td class="annotate">
494 <td class="annotate">
497 <a href="/annotate/3e1445510fe7/primes.py#30"
495 <a href="/annotate/3e1445510fe7/primes.py#30"
498 title="3e1445510fe7: a">test@0</a>
496 title="3e1445510fe7: a">test@0</a>
499 </td>
497 </td>
500 <td class="source"><a href="#l30" id="l30"> 30</a> <span class="n">n</span> <span class="o">=</span> <span class="mf">10</span></td>
498 <td class="source"><a href="#l30" id="l30"> 30</a> <span class="n">n</span> <span class="o">=</span> <span class="mf">10</span></td>
501 </tr>
499 </tr>
502 <tr class="parity0">
500 <tr class="parity0">
503 <td class="annotate">
501 <td class="annotate">
504 <a href="/annotate/3e1445510fe7/primes.py#31"
502 <a href="/annotate/3e1445510fe7/primes.py#31"
505 title="3e1445510fe7: a">test@0</a>
503 title="3e1445510fe7: a">test@0</a>
506 </td>
504 </td>
507 <td class="source"><a href="#l31" id="l31"> 31</a> <span class="n">p</span> <span class="o">=</span> <span class="n">primes</span><span class="p">()</span></td>
505 <td class="source"><a href="#l31" id="l31"> 31</a> <span class="n">p</span> <span class="o">=</span> <span class="n">primes</span><span class="p">()</span></td>
508 </tr>
506 </tr>
509 <tr class="parity1">
507 <tr class="parity1">
510 <td class="annotate">
508 <td class="annotate">
511 <a href="/annotate/3e1445510fe7/primes.py#32"
509 <a href="/annotate/3e1445510fe7/primes.py#32"
512 title="3e1445510fe7: a">test@0</a>
510 title="3e1445510fe7: a">test@0</a>
513 </td>
511 </td>
514 <td class="source"><a href="#l32" id="l32"> 32</a> <span class="kn">print</span> <span class="s">&quot;The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">)))</span></td>
512 <td class="source"><a href="#l32" id="l32"> 32</a> <span class="kn">print</span> <span class="s">&quot;The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">)))</span></td>
515 </tr>
513 </tr>
516 </table>
514 </table>
517 </div>
515 </div>
518 </div>
516 </div>
519 </div>
517 </div>
520
518
521
519
522
520
523 </body>
521 </body>
524 </html>
522 </html>
525
523
526 % hgweb fileannotate, raw
524 % hgweb fileannotate, raw
527
525
528 % hgweb filerevision, raw
526 % hgweb filerevision, raw
529
527
530 % hgweb highlightcss friendly
528 % hgweb highlightcss friendly
531 200 Script output follows
529 200 Script output follows
532
530
533 /* pygments_style = friendly */
531 /* pygments_style = friendly */
534
532
535 % errors encountered
533 % errors encountered
536 % hg serve again
534 % hg serve again
537 % hgweb highlightcss fruity
535 % hgweb highlightcss fruity
538 200 Script output follows
536 200 Script output follows
539
537
540 /* pygments_style = fruity */
538 /* pygments_style = fruity */
541
539
542 % errors encountered
540 % errors encountered
General Comments 0
You need to be logged in to leave comments. Login now