Show More
@@ -82,7 +82,7 b" fileline = '" | |||||
82 | annotateline = ' |
|
82 | annotateline = ' | |
83 | <tr class="parity{parity}"> |
|
83 | <tr class="parity{parity}"> | |
84 | <td class="linenr"> |
|
84 | <td class="linenr"> | |
85 | <a href="{url}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#{targetline}" |
|
85 | <a href="{url}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}" | |
86 | title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a> |
|
86 | title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a> | |
87 | </td> |
|
87 | </td> | |
88 | <td class="lineno"> |
|
88 | <td class="lineno"> |
@@ -70,7 +70,7 b' filelogentry = filelogentry.tmpl' | |||||
70 | annotateline = ' |
|
70 | annotateline = ' | |
71 | <tr class="parity{parity}"> |
|
71 | <tr class="parity{parity}"> | |
72 | <td class="annotate"> |
|
72 | <td class="annotate"> | |
73 | <a href="{url}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#{targetline}" |
|
73 | <a href="{url}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}" | |
74 | title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a> |
|
74 | title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a> | |
75 | </td> |
|
75 | </td> | |
76 | <td class="source"><a href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</td> |
|
76 | <td class="source"><a href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</td> |
@@ -273,224 +273,224 b' hgweb fileannotate, html' | |||||
273 |
|
273 | |||
274 | <tr class="parity0"> |
|
274 | <tr class="parity0"> | |
275 | <td class="annotate"> |
|
275 | <td class="annotate"> | |
276 | <a href="/annotate/853dcd4de2a6/primes.py#1" |
|
276 | <a href="/annotate/853dcd4de2a6/primes.py#l1" | |
277 | title="853dcd4de2a6: a">test@0</a> |
|
277 | title="853dcd4de2a6: a">test@0</a> | |
278 | </td> |
|
278 | </td> | |
279 | <td class="source"><a href="#l1" id="l1"> 1</a> <span class="c">#!/usr/bin/env python</span></td> |
|
279 | <td class="source"><a href="#l1" id="l1"> 1</a> <span class="c">#!/usr/bin/env python</span></td> | |
280 | </tr> |
|
280 | </tr> | |
281 | <tr class="parity1"> |
|
281 | <tr class="parity1"> | |
282 | <td class="annotate"> |
|
282 | <td class="annotate"> | |
283 | <a href="/annotate/853dcd4de2a6/primes.py#2" |
|
283 | <a href="/annotate/853dcd4de2a6/primes.py#l2" | |
284 | title="853dcd4de2a6: a">test@0</a> |
|
284 | title="853dcd4de2a6: a">test@0</a> | |
285 | </td> |
|
285 | </td> | |
286 | <td class="source"><a href="#l2" id="l2"> 2</a> </td> |
|
286 | <td class="source"><a href="#l2" id="l2"> 2</a> </td> | |
287 | </tr> |
|
287 | </tr> | |
288 | <tr class="parity0"> |
|
288 | <tr class="parity0"> | |
289 | <td class="annotate"> |
|
289 | <td class="annotate"> | |
290 | <a href="/annotate/853dcd4de2a6/primes.py#3" |
|
290 | <a href="/annotate/853dcd4de2a6/primes.py#l3" | |
291 | title="853dcd4de2a6: a">test@0</a> |
|
291 | title="853dcd4de2a6: a">test@0</a> | |
292 | </td> |
|
292 | </td> | |
293 | <td class="source"><a href="#l3" id="l3"> 3</a> <span class="sd">"""Fun with generators. Corresponding Haskell implementation:</span></td> |
|
293 | <td class="source"><a href="#l3" id="l3"> 3</a> <span class="sd">"""Fun with generators. Corresponding Haskell implementation:</span></td> | |
294 | </tr> |
|
294 | </tr> | |
295 | <tr class="parity1"> |
|
295 | <tr class="parity1"> | |
296 | <td class="annotate"> |
|
296 | <td class="annotate"> | |
297 | <a href="/annotate/853dcd4de2a6/primes.py#4" |
|
297 | <a href="/annotate/853dcd4de2a6/primes.py#l4" | |
298 | title="853dcd4de2a6: a">test@0</a> |
|
298 | title="853dcd4de2a6: a">test@0</a> | |
299 | </td> |
|
299 | </td> | |
300 | <td class="source"><a href="#l4" id="l4"> 4</a> </td> |
|
300 | <td class="source"><a href="#l4" id="l4"> 4</a> </td> | |
301 | </tr> |
|
301 | </tr> | |
302 | <tr class="parity0"> |
|
302 | <tr class="parity0"> | |
303 | <td class="annotate"> |
|
303 | <td class="annotate"> | |
304 | <a href="/annotate/853dcd4de2a6/primes.py#5" |
|
304 | <a href="/annotate/853dcd4de2a6/primes.py#l5" | |
305 | title="853dcd4de2a6: a">test@0</a> |
|
305 | title="853dcd4de2a6: a">test@0</a> | |
306 | </td> |
|
306 | </td> | |
307 | <td class="source"><a href="#l5" id="l5"> 5</a> <span class="sd">primes = 2 : sieve [3, 5..]</span></td> |
|
307 | <td class="source"><a href="#l5" id="l5"> 5</a> <span class="sd">primes = 2 : sieve [3, 5..]</span></td> | |
308 | </tr> |
|
308 | </tr> | |
309 | <tr class="parity1"> |
|
309 | <tr class="parity1"> | |
310 | <td class="annotate"> |
|
310 | <td class="annotate"> | |
311 | <a href="/annotate/853dcd4de2a6/primes.py#6" |
|
311 | <a href="/annotate/853dcd4de2a6/primes.py#l6" | |
312 | title="853dcd4de2a6: a">test@0</a> |
|
312 | title="853dcd4de2a6: a">test@0</a> | |
313 | </td> |
|
313 | </td> | |
314 | <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> |
|
314 | <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> | |
315 | </tr> |
|
315 | </tr> | |
316 | <tr class="parity0"> |
|
316 | <tr class="parity0"> | |
317 | <td class="annotate"> |
|
317 | <td class="annotate"> | |
318 | <a href="/annotate/853dcd4de2a6/primes.py#7" |
|
318 | <a href="/annotate/853dcd4de2a6/primes.py#l7" | |
319 | title="853dcd4de2a6: a">test@0</a> |
|
319 | title="853dcd4de2a6: a">test@0</a> | |
320 | </td> |
|
320 | </td> | |
321 | <td class="source"><a href="#l7" id="l7"> 7</a> <span class="sd">"""</span></td> |
|
321 | <td class="source"><a href="#l7" id="l7"> 7</a> <span class="sd">"""</span></td> | |
322 | </tr> |
|
322 | </tr> | |
323 | <tr class="parity1"> |
|
323 | <tr class="parity1"> | |
324 | <td class="annotate"> |
|
324 | <td class="annotate"> | |
325 | <a href="/annotate/853dcd4de2a6/primes.py#8" |
|
325 | <a href="/annotate/853dcd4de2a6/primes.py#l8" | |
326 | title="853dcd4de2a6: a">test@0</a> |
|
326 | title="853dcd4de2a6: a">test@0</a> | |
327 | </td> |
|
327 | </td> | |
328 | <td class="source"><a href="#l8" id="l8"> 8</a> </td> |
|
328 | <td class="source"><a href="#l8" id="l8"> 8</a> </td> | |
329 | </tr> |
|
329 | </tr> | |
330 | <tr class="parity0"> |
|
330 | <tr class="parity0"> | |
331 | <td class="annotate"> |
|
331 | <td class="annotate"> | |
332 | <a href="/annotate/853dcd4de2a6/primes.py#9" |
|
332 | <a href="/annotate/853dcd4de2a6/primes.py#l9" | |
333 | title="853dcd4de2a6: a">test@0</a> |
|
333 | title="853dcd4de2a6: a">test@0</a> | |
334 | </td> |
|
334 | </td> | |
335 | <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> |
|
335 | <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> | |
336 | </tr> |
|
336 | </tr> | |
337 | <tr class="parity1"> |
|
337 | <tr class="parity1"> | |
338 | <td class="annotate"> |
|
338 | <td class="annotate"> | |
339 | <a href="/annotate/853dcd4de2a6/primes.py#10" |
|
339 | <a href="/annotate/853dcd4de2a6/primes.py#l10" | |
340 | title="853dcd4de2a6: a">test@0</a> |
|
340 | title="853dcd4de2a6: a">test@0</a> | |
341 | </td> |
|
341 | </td> | |
342 | <td class="source"><a href="#l10" id="l10"> 10</a> </td> |
|
342 | <td class="source"><a href="#l10" id="l10"> 10</a> </td> | |
343 | </tr> |
|
343 | </tr> | |
344 | <tr class="parity0"> |
|
344 | <tr class="parity0"> | |
345 | <td class="annotate"> |
|
345 | <td class="annotate"> | |
346 | <a href="/annotate/853dcd4de2a6/primes.py#11" |
|
346 | <a href="/annotate/853dcd4de2a6/primes.py#l11" | |
347 | title="853dcd4de2a6: a">test@0</a> |
|
347 | title="853dcd4de2a6: a">test@0</a> | |
348 | </td> |
|
348 | </td> | |
349 | <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> |
|
349 | <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> | |
350 | </tr> |
|
350 | </tr> | |
351 | <tr class="parity1"> |
|
351 | <tr class="parity1"> | |
352 | <td class="annotate"> |
|
352 | <td class="annotate"> | |
353 | <a href="/annotate/853dcd4de2a6/primes.py#12" |
|
353 | <a href="/annotate/853dcd4de2a6/primes.py#l12" | |
354 | title="853dcd4de2a6: a">test@0</a> |
|
354 | title="853dcd4de2a6: a">test@0</a> | |
355 | </td> |
|
355 | </td> | |
356 | <td class="source"><a href="#l12" id="l12"> 12</a> <span class="sd">"""Generate all primes."""</span></td> |
|
356 | <td class="source"><a href="#l12" id="l12"> 12</a> <span class="sd">"""Generate all primes."""</span></td> | |
357 | </tr> |
|
357 | </tr> | |
358 | <tr class="parity0"> |
|
358 | <tr class="parity0"> | |
359 | <td class="annotate"> |
|
359 | <td class="annotate"> | |
360 | <a href="/annotate/853dcd4de2a6/primes.py#13" |
|
360 | <a href="/annotate/853dcd4de2a6/primes.py#l13" | |
361 | title="853dcd4de2a6: a">test@0</a> |
|
361 | title="853dcd4de2a6: a">test@0</a> | |
362 | </td> |
|
362 | </td> | |
363 | <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> |
|
363 | <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> | |
364 | </tr> |
|
364 | </tr> | |
365 | <tr class="parity1"> |
|
365 | <tr class="parity1"> | |
366 | <td class="annotate"> |
|
366 | <td class="annotate"> | |
367 | <a href="/annotate/853dcd4de2a6/primes.py#14" |
|
367 | <a href="/annotate/853dcd4de2a6/primes.py#l14" | |
368 | title="853dcd4de2a6: a">test@0</a> |
|
368 | title="853dcd4de2a6: a">test@0</a> | |
369 | </td> |
|
369 | </td> | |
370 | <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> |
|
370 | <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> | |
371 | </tr> |
|
371 | </tr> | |
372 | <tr class="parity0"> |
|
372 | <tr class="parity0"> | |
373 | <td class="annotate"> |
|
373 | <td class="annotate"> | |
374 | <a href="/annotate/853dcd4de2a6/primes.py#15" |
|
374 | <a href="/annotate/853dcd4de2a6/primes.py#l15" | |
375 | title="853dcd4de2a6: a">test@0</a> |
|
375 | title="853dcd4de2a6: a">test@0</a> | |
376 | </td> |
|
376 | </td> | |
377 | <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> |
|
377 | <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> | |
378 | </tr> |
|
378 | </tr> | |
379 | <tr class="parity1"> |
|
379 | <tr class="parity1"> | |
380 | <td class="annotate"> |
|
380 | <td class="annotate"> | |
381 | <a href="/annotate/853dcd4de2a6/primes.py#16" |
|
381 | <a href="/annotate/853dcd4de2a6/primes.py#l16" | |
382 | title="853dcd4de2a6: a">test@0</a> |
|
382 | title="853dcd4de2a6: a">test@0</a> | |
383 | </td> |
|
383 | </td> | |
384 | <td class="source"><a href="#l16" id="l16"> 16</a> <span class="c"># infinite recursion.</span></td> |
|
384 | <td class="source"><a href="#l16" id="l16"> 16</a> <span class="c"># infinite recursion.</span></td> | |
385 | </tr> |
|
385 | </tr> | |
386 | <tr class="parity0"> |
|
386 | <tr class="parity0"> | |
387 | <td class="annotate"> |
|
387 | <td class="annotate"> | |
388 | <a href="/annotate/853dcd4de2a6/primes.py#17" |
|
388 | <a href="/annotate/853dcd4de2a6/primes.py#l17" | |
389 | title="853dcd4de2a6: a">test@0</a> |
|
389 | title="853dcd4de2a6: a">test@0</a> | |
390 | </td> |
|
390 | </td> | |
391 | <td class="source"><a href="#l17" id="l17"> 17</a> <span class="kn">yield</span> <span class="n">p</span></td> |
|
391 | <td class="source"><a href="#l17" id="l17"> 17</a> <span class="kn">yield</span> <span class="n">p</span></td> | |
392 | </tr> |
|
392 | </tr> | |
393 | <tr class="parity1"> |
|
393 | <tr class="parity1"> | |
394 | <td class="annotate"> |
|
394 | <td class="annotate"> | |
395 | <a href="/annotate/853dcd4de2a6/primes.py#18" |
|
395 | <a href="/annotate/853dcd4de2a6/primes.py#l18" | |
396 | title="853dcd4de2a6: a">test@0</a> |
|
396 | title="853dcd4de2a6: a">test@0</a> | |
397 | </td> |
|
397 | </td> | |
398 | <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> |
|
398 | <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> | |
399 | </tr> |
|
399 | </tr> | |
400 | <tr class="parity0"> |
|
400 | <tr class="parity0"> | |
401 | <td class="annotate"> |
|
401 | <td class="annotate"> | |
402 | <a href="/annotate/853dcd4de2a6/primes.py#19" |
|
402 | <a href="/annotate/853dcd4de2a6/primes.py#l19" | |
403 | title="853dcd4de2a6: a">test@0</a> |
|
403 | title="853dcd4de2a6: a">test@0</a> | |
404 | </td> |
|
404 | </td> | |
405 | <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> |
|
405 | <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> | |
406 | </tr> |
|
406 | </tr> | |
407 | <tr class="parity1"> |
|
407 | <tr class="parity1"> | |
408 | <td class="annotate"> |
|
408 | <td class="annotate"> | |
409 | <a href="/annotate/853dcd4de2a6/primes.py#20" |
|
409 | <a href="/annotate/853dcd4de2a6/primes.py#l20" | |
410 | title="853dcd4de2a6: a">test@0</a> |
|
410 | title="853dcd4de2a6: a">test@0</a> | |
411 | </td> |
|
411 | </td> | |
412 | <td class="source"><a href="#l20" id="l20"> 20</a> <span class="kn">yield</span> <span class="n">n</span></td> |
|
412 | <td class="source"><a href="#l20" id="l20"> 20</a> <span class="kn">yield</span> <span class="n">n</span></td> | |
413 | </tr> |
|
413 | </tr> | |
414 | <tr class="parity0"> |
|
414 | <tr class="parity0"> | |
415 | <td class="annotate"> |
|
415 | <td class="annotate"> | |
416 | <a href="/annotate/853dcd4de2a6/primes.py#21" |
|
416 | <a href="/annotate/853dcd4de2a6/primes.py#l21" | |
417 | title="853dcd4de2a6: a">test@0</a> |
|
417 | title="853dcd4de2a6: a">test@0</a> | |
418 | </td> |
|
418 | </td> | |
419 | <td class="source"><a href="#l21" id="l21"> 21</a> </td> |
|
419 | <td class="source"><a href="#l21" id="l21"> 21</a> </td> | |
420 | </tr> |
|
420 | </tr> | |
421 | <tr class="parity1"> |
|
421 | <tr class="parity1"> | |
422 | <td class="annotate"> |
|
422 | <td class="annotate"> | |
423 | <a href="/annotate/853dcd4de2a6/primes.py#22" |
|
423 | <a href="/annotate/853dcd4de2a6/primes.py#l22" | |
424 | title="853dcd4de2a6: a">test@0</a> |
|
424 | title="853dcd4de2a6: a">test@0</a> | |
425 | </td> |
|
425 | </td> | |
426 | <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> |
|
426 | <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> | |
427 | </tr> |
|
427 | </tr> | |
428 | <tr class="parity0"> |
|
428 | <tr class="parity0"> | |
429 | <td class="annotate"> |
|
429 | <td class="annotate"> | |
430 | <a href="/annotate/853dcd4de2a6/primes.py#23" |
|
430 | <a href="/annotate/853dcd4de2a6/primes.py#l23" | |
431 | title="853dcd4de2a6: a">test@0</a> |
|
431 | title="853dcd4de2a6: a">test@0</a> | |
432 | </td> |
|
432 | </td> | |
433 | <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> |
|
433 | <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> | |
434 | </tr> |
|
434 | </tr> | |
435 | <tr class="parity1"> |
|
435 | <tr class="parity1"> | |
436 | <td class="annotate"> |
|
436 | <td class="annotate"> | |
437 | <a href="/annotate/853dcd4de2a6/primes.py#24" |
|
437 | <a href="/annotate/853dcd4de2a6/primes.py#l24" | |
438 | title="853dcd4de2a6: a">test@0</a> |
|
438 | title="853dcd4de2a6: a">test@0</a> | |
439 | </td> |
|
439 | </td> | |
440 | <td class="source"><a href="#l24" id="l24"> 24</a> </td> |
|
440 | <td class="source"><a href="#l24" id="l24"> 24</a> </td> | |
441 | </tr> |
|
441 | </tr> | |
442 | <tr class="parity0"> |
|
442 | <tr class="parity0"> | |
443 | <td class="annotate"> |
|
443 | <td class="annotate"> | |
444 | <a href="/annotate/853dcd4de2a6/primes.py#25" |
|
444 | <a href="/annotate/853dcd4de2a6/primes.py#l25" | |
445 | title="853dcd4de2a6: a">test@0</a> |
|
445 | title="853dcd4de2a6: a">test@0</a> | |
446 | </td> |
|
446 | </td> | |
447 | <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> |
|
447 | <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> | |
448 | </tr> |
|
448 | </tr> | |
449 | <tr class="parity1"> |
|
449 | <tr class="parity1"> | |
450 | <td class="annotate"> |
|
450 | <td class="annotate"> | |
451 | <a href="/annotate/853dcd4de2a6/primes.py#26" |
|
451 | <a href="/annotate/853dcd4de2a6/primes.py#l26" | |
452 | title="853dcd4de2a6: a">test@0</a> |
|
452 | title="853dcd4de2a6: a">test@0</a> | |
453 | </td> |
|
453 | </td> | |
454 | <td class="source"><a href="#l26" id="l26"> 26</a> <span class="kn">import</span> <span class="nn">sys</span></td> |
|
454 | <td class="source"><a href="#l26" id="l26"> 26</a> <span class="kn">import</span> <span class="nn">sys</span></td> | |
455 | </tr> |
|
455 | </tr> | |
456 | <tr class="parity0"> |
|
456 | <tr class="parity0"> | |
457 | <td class="annotate"> |
|
457 | <td class="annotate"> | |
458 | <a href="/annotate/853dcd4de2a6/primes.py#27" |
|
458 | <a href="/annotate/853dcd4de2a6/primes.py#l27" | |
459 | title="853dcd4de2a6: a">test@0</a> |
|
459 | title="853dcd4de2a6: a">test@0</a> | |
460 | </td> |
|
460 | </td> | |
461 | <td class="source"><a href="#l27" id="l27"> 27</a> <span class="kn">try</span><span class="p">:</span></td> |
|
461 | <td class="source"><a href="#l27" id="l27"> 27</a> <span class="kn">try</span><span class="p">:</span></td> | |
462 | </tr> |
|
462 | </tr> | |
463 | <tr class="parity1"> |
|
463 | <tr class="parity1"> | |
464 | <td class="annotate"> |
|
464 | <td class="annotate"> | |
465 | <a href="/annotate/853dcd4de2a6/primes.py#28" |
|
465 | <a href="/annotate/853dcd4de2a6/primes.py#l28" | |
466 | title="853dcd4de2a6: a">test@0</a> |
|
466 | title="853dcd4de2a6: a">test@0</a> | |
467 | </td> |
|
467 | </td> | |
468 | <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> |
|
468 | <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> | |
469 | </tr> |
|
469 | </tr> | |
470 | <tr class="parity0"> |
|
470 | <tr class="parity0"> | |
471 | <td class="annotate"> |
|
471 | <td class="annotate"> | |
472 | <a href="/annotate/853dcd4de2a6/primes.py#29" |
|
472 | <a href="/annotate/853dcd4de2a6/primes.py#l29" | |
473 | title="853dcd4de2a6: a">test@0</a> |
|
473 | title="853dcd4de2a6: a">test@0</a> | |
474 | </td> |
|
474 | </td> | |
475 | <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> |
|
475 | <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> | |
476 | </tr> |
|
476 | </tr> | |
477 | <tr class="parity1"> |
|
477 | <tr class="parity1"> | |
478 | <td class="annotate"> |
|
478 | <td class="annotate"> | |
479 | <a href="/annotate/853dcd4de2a6/primes.py#30" |
|
479 | <a href="/annotate/853dcd4de2a6/primes.py#l30" | |
480 | title="853dcd4de2a6: a">test@0</a> |
|
480 | title="853dcd4de2a6: a">test@0</a> | |
481 | </td> |
|
481 | </td> | |
482 | <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> |
|
482 | <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> | |
483 | </tr> |
|
483 | </tr> | |
484 | <tr class="parity0"> |
|
484 | <tr class="parity0"> | |
485 | <td class="annotate"> |
|
485 | <td class="annotate"> | |
486 | <a href="/annotate/853dcd4de2a6/primes.py#31" |
|
486 | <a href="/annotate/853dcd4de2a6/primes.py#l31" | |
487 | title="853dcd4de2a6: a">test@0</a> |
|
487 | title="853dcd4de2a6: a">test@0</a> | |
488 | </td> |
|
488 | </td> | |
489 | <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> |
|
489 | <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> | |
490 | </tr> |
|
490 | </tr> | |
491 | <tr class="parity1"> |
|
491 | <tr class="parity1"> | |
492 | <td class="annotate"> |
|
492 | <td class="annotate"> | |
493 | <a href="/annotate/853dcd4de2a6/primes.py#32" |
|
493 | <a href="/annotate/853dcd4de2a6/primes.py#l32" | |
494 | title="853dcd4de2a6: a">test@0</a> |
|
494 | title="853dcd4de2a6: a">test@0</a> | |
495 | </td> |
|
495 | </td> | |
496 | <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> |
|
496 | <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> |
General Comments 0
You need to be logged in to leave comments.
Login now