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