<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>List Comprehension on Karpoke - Just Another Blog</title><link>http://karpoke.ignaciocano.com/tags/list-comprehension/</link><description>Recent content in List Comprehension on Karpoke - Just Another Blog</description><generator>Hugo -- 0.159.0</generator><language>es</language><lastBuildDate>Sat, 26 Feb 2011 00:49:00 +0100</lastBuildDate><atom:link href="http://karpoke.ignaciocano.com/tags/list-comprehension/index.xml" rel="self" type="application/rss+xml"/><item><title>Mystery</title><link>http://karpoke.ignaciocano.com/2011/02/26/mystery/</link><pubDate>Sat, 26 Feb 2011 00:49:00 +0100</pubDate><guid>http://karpoke.ignaciocano.com/2011/02/26/mystery/</guid><description>&lt;p&gt;Casi parece que está escrito en chino, o mejor dicho en &lt;em&gt;brainfuck&lt;/em&gt;, o
puede que no sea muy &lt;em&gt;&lt;a href="http://karpoke.ignaciocano.com/2011/02/26/python-zen/"&gt;zen&lt;/a&gt;&lt;/em&gt;, pero no deja de ser &lt;em&gt;&lt;a href="http://blog.garlicsim.org/post/3504711416#comment-156082460"&gt;elegante&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;def mystery(n):
a = list(range(n))
[[(yield i) for a[::i] in [([0]*n)[::i]]] for i in a[2:] if a[i]]
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;El nombre de la función pretende no dar pistas para que intentemos
averiguar qué hace exactamente esta función. He aquí una pista:&lt;/p&gt;
&lt;p&gt;&lt;img alt="prime numnbers" loading="lazy" src="http://karpoke.ignaciocano.com/images/prime-numbers-300x300.gif" title="prime-numbers"&gt;&lt;/p&gt;
&lt;p&gt;Fuente: &lt;a href="http://www.numberspiral.com/"&gt;numberspiral.com&lt;/a&gt;&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; f = mystery(20)
&amp;gt;&amp;gt;&amp;gt; try:
... while True:
... print f.next()
... except StopIteration:
... pass
2
3
5
7
11
13
17
19
&lt;/code&gt;&lt;/pre&gt;</description></item></channel></rss>