<?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>Yield on Karpoke - Just Another Blog</title><link>http://karpoke.ignaciocano.com/tags/yield/</link><description>Recent content in Yield on Karpoke - Just Another Blog</description><generator>Hugo -- 0.159.0</generator><language>es</language><lastBuildDate>Sat, 12 Mar 2011 13:11:00 +0100</lastBuildDate><atom:link href="http://karpoke.ignaciocano.com/tags/yield/index.xml" rel="self" type="application/rss+xml"/><item><title>ls sin ls</title><link>http://karpoke.ignaciocano.com/2011/03/12/ls-sin-ls/</link><pubDate>Sat, 12 Mar 2011 13:11:00 +0100</pubDate><guid>http://karpoke.ignaciocano.com/2011/03/12/ls-sin-ls/</guid><description>&lt;p&gt;En bash:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;$ for i in *; do echo $i; done
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;img alt="ls" loading="lazy" src="http://karpoke.ignaciocano.com/images/ls-300x232.jpg"&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Fuente: &lt;a href="http://nfosolutions.com/"&gt;nfosolutions.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;En &lt;a href="http://snippets.dzone.com/posts/show/2735"&gt;C&lt;/a&gt;:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/*
*
* Esempio che scansiona una cartella stampando a video i file in essa
* contenuti.
*/
&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex="0"&gt;&lt;code&gt;#include
#include
#include
#include
&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex="0"&gt;&lt;code&gt;int main(int argc, char *argv[])
{
DIR *dir;
struct dirent *drent;
&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex="0"&gt;&lt;code&gt; if(argc &amp;lt; 2)
{
fprintf(stderr, &amp;#34;%s \n&amp;#34;, argv[0]);
return EXIT_FAILURE;
}
&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex="0"&gt;&lt;code&gt; if((dir = opendir(argv[1])) == NULL)
{
fprintf(stderr, &amp;#34;Errore opendir()\n&amp;#34;);
return EXIT_FAILURE;
}
&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex="0"&gt;&lt;code&gt; while((drent = readdir(dir)) != NULL)
{
fprintf(stdout, &amp;#34;--&amp;gt; %s\n&amp;#34;, drent-&amp;gt;d_name);
}
&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex="0"&gt;&lt;code&gt; if(closedir(dir) &amp;lt; 0)
{
fprintf(stderr, &amp;#34;Errore closedir()\n&amp;#34;);
return EXIT_FAILURE;
}
}
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;En Python:&lt;/p&gt;</description></item><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>