<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Fibers: a solution</title>
	<atom:link href="http://blog.higher-order.net/2008/08/15/fibers-a-solution/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.higher-order.net/2008/08/15/fibers-a-solution/</link>
	<description>topics: functional programming, concurrency, web-development, REST, dynamic languages</description>
	<lastBuildDate>Tue, 17 Aug 2010 07:43:11 -0700</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: admin</title>
		<link>http://blog.higher-order.net/2008/08/15/fibers-a-solution/comment-page-1/#comment-24</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Fri, 22 Aug 2008 07:42:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.higher-order.net/?p=77#comment-24</guid>
		<description>Here is my own solution.

&lt;pre&gt;&lt;tt&gt;&lt;span class=&quot;keyword&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; FiberStack&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; initialize &lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;type&quot;&gt;@f&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; &lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; Fiber&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt;new &lt;/span&gt;&lt;span class=&quot;cbracket&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt;irb&lt;/span&gt;&lt;span class=&quot;cbracket&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;type&quot;&gt;@f&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt;resume &lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;#start irb loop&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt; &lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; empty?&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;    size &lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; &lt;/span&gt;&lt;span class=&quot;number&quot;&gt;0&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt; &lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; size&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;type&quot;&gt;@f&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt;resume&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;(:&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt;tap &lt;/span&gt;&lt;span class=&quot;cbracket&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;type&quot;&gt;@f&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt;resume&lt;/span&gt;&lt;span class=&quot;cbracket&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;  &lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; push o&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;type&quot;&gt;@f&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt;resume &lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; o&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;  &lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; pop&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;type&quot;&gt;@f&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt;resume &lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt;pop &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;unless&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; empty?&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;  &lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;  private&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; irb o &lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; size &lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; &lt;/span&gt;&lt;span class=&quot;number&quot;&gt;0&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;    popped &lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; &lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;#initially nothing has been popped&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;loop&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;do&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;      cmd&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; val &lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; Fiber&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;yield&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; popped&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; o &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; cmd &lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; &lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt;pop &lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;#pop command, return one level on call stack&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; cmd &lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; &lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt;size&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;        Fiber&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;yield&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; size &lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;else&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;        popped &lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; irb val&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; size&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt; &lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;#recursive call to put val on call stack&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;normal&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
&lt;/tt&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Here is my own solution.</p>
<pre><tt><span class="keyword">class</span><span class="normal"> FiberStack</span>
<span class="normal">  </span><span class="keyword">def</span><span class="normal"> initialize </span>
<span class="normal">    </span><span class="type">@f</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> Fiber</span><span class="symbol">.</span><span class="normal">new </span><span class="cbracket">{</span><span class="normal">irb</span><span class="cbracket">}</span>
<span class="normal">    </span><span class="type">@f</span><span class="symbol">.</span><span class="normal">resume </span><span class="comment">#start irb loop</span>
<span class="normal">  </span><span class="keyword">end</span>
<span class="normal"> </span>
<span class="normal">  </span><span class="keyword">def</span><span class="normal"> empty?</span>
<span class="normal">    size </span><span class="symbol">==</span><span class="normal"> </span><span class="number">0</span>
<span class="normal">  </span><span class="keyword">end</span>
<span class="normal"> </span>
<span class="normal">  </span><span class="keyword">def</span><span class="normal"> size</span>
<span class="normal">    </span><span class="type">@f</span><span class="symbol">.</span><span class="normal">resume</span><span class="symbol">(:</span><span class="normal">size</span><span class="symbol">).</span><span class="normal">tap </span><span class="cbracket">{</span><span class="type">@f</span><span class="symbol">.</span><span class="normal">resume</span><span class="cbracket">}</span>
<span class="normal">  </span><span class="keyword">end</span>
<span class="normal">  </span>
<span class="normal">  </span><span class="keyword">def</span><span class="normal"> push o</span>
<span class="normal">    </span><span class="type">@f</span><span class="symbol">.</span><span class="normal">resume </span><span class="symbol">:</span><span class="normal">push</span><span class="symbol">,</span><span class="normal"> o</span>
<span class="normal">  </span><span class="keyword">end</span>
<span class="normal">  </span>
<span class="normal">  </span><span class="keyword">def</span><span class="normal"> pop</span>
<span class="normal">    </span><span class="type">@f</span><span class="symbol">.</span><span class="normal">resume </span><span class="symbol">:</span><span class="normal">pop </span><span class="keyword">unless</span><span class="normal"> empty?</span>
<span class="normal">  </span><span class="keyword">end</span>
<span class="normal">  </span>
<span class="normal">  private</span>
<span class="normal">  </span><span class="keyword">def</span><span class="normal"> irb o </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">nil</span><span class="symbol">,</span><span class="normal"> size </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span>
<span class="normal">    popped </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">nil</span><span class="normal"> </span><span class="comment">#initially nothing has been popped</span>
<span class="normal">    </span><span class="keyword">loop</span><span class="normal"> </span><span class="keyword">do</span>
<span class="normal">      cmd</span><span class="symbol">,</span><span class="normal"> val </span><span class="symbol">=</span><span class="normal"> Fiber</span><span class="symbol">.</span><span class="keyword">yield</span><span class="normal"> popped</span>
<span class="normal">      </span><span class="keyword">return</span><span class="normal"> o </span><span class="keyword">if</span><span class="normal"> cmd </span><span class="symbol">==</span><span class="normal"> </span><span class="symbol">:</span><span class="normal">pop </span><span class="comment">#pop command, return one level on call stack</span>
<span class="normal">      </span><span class="keyword">if</span><span class="normal"> cmd </span><span class="symbol">==</span><span class="normal"> </span><span class="symbol">:</span><span class="normal">size</span>
<span class="normal">        Fiber</span><span class="symbol">.</span><span class="keyword">yield</span><span class="normal"> size </span>
<span class="normal">      </span><span class="keyword">else</span>
<span class="normal">        popped </span><span class="symbol">=</span><span class="normal"> irb val</span><span class="symbol">,</span><span class="normal"> size</span><span class="symbol">+</span><span class="number">1</span><span class="normal"> </span><span class="comment">#recursive call to put val on call stack</span>
<span class="normal">      </span><span class="keyword">end</span>
<span class="normal">    </span><span class="keyword">end</span>
<span class="normal">  </span><span class="keyword">end</span>
<span class="keyword">end</span>
</tt></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://blog.higher-order.net/2008/08/15/fibers-a-solution/comment-page-1/#comment-23</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Fri, 22 Aug 2008 04:42:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.higher-order.net/?p=77#comment-23</guid>
		<description>Exactly ;-)</description>
		<content:encoded><![CDATA[<p>Exactly <img src='http://blog.higher-order.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hongli Lai</title>
		<link>http://blog.higher-order.net/2008/08/15/fibers-a-solution/comment-page-1/#comment-21</link>
		<dc:creator>Hongli Lai</dc:creator>
		<pubDate>Thu, 21 Aug 2008 21:53:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.higher-order.net/?p=77#comment-21</guid>
		<description>http://pastie.org/257599</description>
		<content:encoded><![CDATA[<p><a href="http://pastie.org/257599" rel="nofollow">http://pastie.org/257599</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Higher-Order &#187; Blog Archive &#187; Fibers: an exercise</title>
		<link>http://blog.higher-order.net/2008/08/15/fibers-a-solution/comment-page-1/#comment-15</link>
		<dc:creator>Higher-Order &#187; Blog Archive &#187; Fibers: an exercise</dc:creator>
		<pubDate>Fri, 15 Aug 2008 09:26:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.higher-order.net/?p=77#comment-15</guid>
		<description>[...] don&#8217;t paste code into comments. Instead post solutions as a comment here. Then post a comment here linking to that solution. In this way we won&#8217;t spoil the fun for [...]</description>
		<content:encoded><![CDATA[<p>[...] don&#8217;t paste code into comments. Instead post solutions as a comment here. Then post a comment here linking to that solution. In this way we won&#8217;t spoil the fun for [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
