<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blumenfeld &#38; Maso, Inc. &#187; Brian Maso</title>
	<atom:link href="http://www.blumenfeld-maso.com/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blumenfeld-maso.com</link>
	<description>Cloud, SaaS, and Enterprise Software Design and Development</description>
	<lastBuildDate>Tue, 13 Apr 2010 16:31:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>#UBP10 Hashtag Tracking</title>
		<link>http://www.blumenfeld-maso.com/2010/04/ubp10-hashtag-tracking/</link>
		<comments>http://www.blumenfeld-maso.com/2010/04/ubp10-hashtag-tracking/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 16:26:46 +0000</pubDate>
		<dc:creator>Brian Maso</dc:creator>
				<category><![CDATA[Social Analytics]]></category>

		<guid isPermaLink="false">http://www.blumenfeld-maso.com/?p=182</guid>
		<description><![CDATA[Quietly, Blumenfeld &#38; Maso has been building up a software portfolio for Twitter analytics of the past few months. Last night, we go more than our feet wet with live tracking and reporting for the #UBP10 party from 5 Minutes for Mom (thanks to @momfluential for setting that up.)
Some basic stats to give you a [...]]]></description>
			<content:encoded><![CDATA[<p>Quietly, Blumenfeld &amp; Maso has been building up a software portfolio for Twitter analytics of the past few months. Last night, we go more than our feet wet with live tracking and reporting for the <a title="#UBP10 party" href="http://bit.ly/cbD5UU">#UBP10</a> party from 5 Minutes for Mom (thanks to @<a href="http://www.momfluential.net">momfluential</a> for setting that up.)</p>
<p>Some basic stats to give you a taste of how successful the #UBP10 Twitter party was: <em>15,704</em> tweets from <em>1,204</em> attendees, with combined reach <em>1,159,469</em> followers, and <em>29,397,282</em> unique messages in 7 days. Fully half that traffic came during the 2 hour #UBP10 party last night!</p>
<p>Over the next couple weeks we&#8217;ll be rolling out more and more of our tracking and visualization tools. (Please <a title="Blumenfled &amp; Maso Contact Us" href="/contact-us">contact us</a> for more info if you&#8217;re interested in hearing more!)</p>
<div id="attachment_183" class="wp-caption aligncenter" style="width: 460px"><a href="http://www.blumenfeld-maso.com/wp-content/uploads/2010/04/stats-collage.jpg"><img class="size-full wp-image-183" title="hashtracking-stats-collage" src="http://www.blumenfeld-maso.com/wp-content/uploads/2010/04/stats-collage.jpg" alt="Hastag Tracking Statistics and Analytics" width="450" height="256" /></a><p class="wp-caption-text">Twitter hashtag tracking statistics and analytics</p></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;"><strong>15,704 tweets from 1,204 attendees, with combined reach  1,159,469 followers, and 29,397,282 unique messages</strong></div>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F04%2Fubp10-hashtag-tracking%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F04%2Fubp10-hashtag-tracking%2F&amp;source=bmaso&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.blumenfeld-maso.com/2010/04/ubp10-hashtag-tracking/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Non-Strict + Zip = Fab Fib!</title>
		<link>http://www.blumenfeld-maso.com/2010/04/non-strict-zip-fab-fib/</link>
		<comments>http://www.blumenfeld-maso.com/2010/04/non-strict-zip-fab-fib/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 14:41:14 +0000</pubDate>
		<dc:creator>Brian Maso</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[non-strict]]></category>
		<category><![CDATA[scala]]></category>
		<category><![CDATA[zipper]]></category>

		<guid isPermaLink="false">http://www.blumenfeld-maso.com/?p=163</guid>
		<description><![CDATA[Just reviewed a gem from Programming Scala. Of all the Fibonacci implementations I&#8217;ve seen, my new favorite is below. Its 1 statement long, and there&#8217;s not a recursive function in sight:
If you have not seen that zip trick before, follow me on a little explanation. The code defines a Stream &#8212; a non-strict iterable &#8212; [...]]]></description>
			<content:encoded><![CDATA[<p>Just reviewed a gem from Programming Scala. Of all the Fibonacci implementations I&#8217;ve seen, my new favorite is below. Its 1 statement long, and there&#8217;s not a recursive function in sight:</p>
<div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_about(1)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: block;"><pre class="scala" style="font-family:monospace;">lazy <a href="http://scala-lang.org"><span class="kw1">val</span></a> fib<span class="sy0">:</span> Stream<span class="br0">&#91;</span>Int<span class="br0">&#93;</span> <span class="sy0">=</span>
 Stream.<span class="me1">cons</span><span class="br0">&#40;</span><span class="nu0">0</span>, Stream.<span class="me1">cons</span><span class="br0">&#40;</span><span class="nu0">1</span>, fib.<span class="me1">zip</span><span class="br0">&#40;</span>fib.<span class="me1">tail</span><span class="br0">&#41;</span>.<span class="me1">map</span><span class="br0">&#40;</span>p <span class="sy0">=&gt;</span> p.<span class="sy0">_</span>1 + p.<span class="sy0">_</span>2<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></pre></div></div>
<p>If you have not seen that zip trick before, follow me on a little explanation. The code defines a Stream &#8212; a non-strict iterable &#8212; that begins with two literal values &#8220;0&#8243; and &#8220;1&#8243;. The stream then continues the Fibonacci sequence by zipping the sequence to itself. More specifically, to its own tail sequence.</p>
<p>This figure illustrates what the zipper is creating.</p>
<p><a href="http://www.blumenfeld-maso.com/wp-content/uploads/2010/04/Temp-e1270580117379.png"><img class="aligncenter size-full wp-image-166" title="fab zip fib" src="http://www.blumenfeld-maso.com/wp-content/uploads/2010/04/Temp-e1270580117379.png" alt="Zipping a stream to itself to generate Fibonacci sequence" width="525" height="195" /></a></p>
<p>The tail value of the initial sequence is just the sequence starting with the literal value &#8220;1&#8243;. The zipper creates Pairs out of the each member of the sequence pairwise joined with the next member of the sequence.</p>
<p>The first pair is (0, 1).</p>
<p>The second pair is then (1, 0 + 1) = (1, 1).</p>
<p>The third pair is then (1, 1 + 1) = (1, 2).</p>
<p>The forth pair is then (2, 1 + 2) = (2, 3). And so on.</p>
<p>The coolest part is of course the complete lack of apparent recursion. The whole sequence is lazily evaluated, so the Stream takes up little space &#8212; one new Stream object per element in the sequence.</p>
<h3>Generalizing</h3>
<p>We can generalize this stream-zipping technique. When the value of a Stream element <em>n</em> can be calculated from the previous <em>k</em> sequence members, we can use a k-ary version of this technique. That is, if the stream <em>theStream</em> member <em>n</em> can be defined by some function <em>s</em>:</p>
<p>def theSeq(n) = s(theSeq(n-1), theSeq(n-2), &#8230;, theSeq(n-k))</p>
<p>We can define the stream in a single statement thus:</p>
<ul>
<li>Explicitly define the first <em>k-1</em> stream members</li>
<li>For all other members, perform <em>k-1</em> zips to create a Tuple<em>K</em> of the previous <em>k</em> sequence elements.</li>
<li>A single closure then defines the next element from this Tuple.</li>
</ul>
<p>Here, for example, is a rolling average of the last 4 members of a Stream[Double]:</p>
<div id="wpshdo_2" class="wp-synhighlighter-outer"><div id="wpshdt_2" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_2"></a><a id="wpshat_2" class="wp-synhighlighter-title" href="#codesyntax_2"  onClick="javascript:wpsh_toggleBlock(2)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_2" onClick="javascript:wpsh_code(2)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_print(2)" title="Print code"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_about(2)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_2" class="wp-synhighlighter-inner" style="display: block;"><pre class="scala" style="font-family:monospace;"><a href="http://scala-lang.org"><span class="kw1">val</span></a> data<span class="sy0">:</span> Stream<span class="br0">&#91;</span>Double<span class="br0">&#93;</span> <span class="sy0">=</span> ...
<a href="http://scala-lang.org"><span class="kw1">val</span></a> padded<span class="sy0">_</span>data <span class="sy0">=</span> Stream.<span class="me1">fill</span><span class="br0">&#40;</span><span class="nu0">4</span><span class="br0">&#41;</span><span class="br0">&#40;</span><span class="nu0">0.0</span><span class="br0">&#41;</span> ++ data ++ Stream.<span class="me1">fill</span><span class="br0">&#40;</span><span class="nu0">4</span><span class="br0">&#41;</span><span class="br0">&#40;</span><span class="nu0">0.0</span><span class="br0">&#41;</span>
  <span class="co1">// Note: tail padding not a problem even if data is infinite.</span>
&nbsp;
<span class="coMULTI">/* Here's where the stream is joined to itself. Also,
   mapping the (((Int,Int),Int),Int) to (Int,Int,Int,Int)
   for readability. Can't be recursively defined   */</span>
<a href="http://scala-lang.org"><span class="kw1">def</span></a> zip4<span class="br0">&#91;</span>A<span class="br0">&#93;</span><span class="br0">&#40;</span>str<span class="sy0">:</span> Stream<span class="br0">&#91;</span>A<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">:</span> <span class="br0">&#40;</span>A,A,A,A<span class="br0">&#41;</span> <span class="sy0">=</span>
 <span class="br0">&#40;</span>str zip str.<span class="me1">tail</span> zip str.<span class="me1">tail</span>.<span class="me1">tail</span> zip str.<span class="me1">tail</span>.<span class="me1">tail</span>.<span class="me1">tail</span><span class="br0">&#41;</span> map <span class="br0">&#123;</span> p<span class="sy0">=&gt;</span>
     <span class="br0">&#40;</span>p.<span class="sy0">_</span>1.<span class="sy0">_</span>1.<span class="sy0">_</span>1, p.<span class="sy0">_</span>1.<span class="sy0">_</span>1.<span class="sy0">_</span>2, p.<span class="sy0">_</span>1.<span class="sy0">_</span>2, p.<span class="sy0">_</span>2<span class="br0">&#41;</span><span class="br0">&#125;</span>
&nbsp;
<span class="coMULTI">/* Could be recursively defined in terms of
   base type Product */</span>
<a href="http://scala-lang.org"><span class="kw1">def</span></a> avg4<span class="br0">&#40;</span>p<span class="sy0">:</span> <span class="br0">&#40;</span>Double,Double,Double,Double<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">:</span> Double <span class="sy0">=</span>
 <span class="br0">&#40;</span>p.<span class="sy0">_</span>1, p.<span class="sy0">_</span>2, p.<span class="sy0">_</span>3, p.<span class="sy0">_</span>4<span class="br0">&#41;</span> / <span class="nu0">4</span>
&nbsp;
<span class="coMULTI">/* Finally, generating the rolling-average stream */</span>
lazy <a href="http://scala-lang.org"><span class="kw1">val</span></a> avg<span class="sy0">_</span>rolling<span class="sy0">:</span> Stream<span class="br0">&#91;</span>Double<span class="br0">&#93;</span> <span class="sy0">=</span>
 zip4<span class="br0">&#40;</span>padded<span class="sy0">_</span>data<span class="br0">&#41;</span> map <span class="br0">&#40;</span>avg4<span class="br0">&#41;</span></pre></div></div>
<p>You can use Iterator.sliding(n) to get a similar effect. And that does work on infinite, non-strict streams. Personally, I just though this technique was so cool, and it does have the benefit of strongly-typed tuples. (Iterator.sliding() simple provides more Streams. Try it out if you&#8217;re curious.)
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F04%2Fnon-strict-zip-fab-fib%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F04%2Fnon-strict-zip-fab-fib%2F&amp;source=bmaso&amp;style=normal&amp;service=bit.ly&amp;hashtags=non-strict,scala,zipper" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.blumenfeld-maso.com/2010/04/non-strict-zip-fab-fib/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Logic, Fallacy, and Dobie Gillis</title>
		<link>http://www.blumenfeld-maso.com/2010/03/logic-fallacy-and-dobie-gillis/</link>
		<comments>http://www.blumenfeld-maso.com/2010/03/logic-fallacy-and-dobie-gillis/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 04:11:45 +0000</pubDate>
		<dc:creator>Brian Maso</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blumenfeld-maso.com/?p=155</guid>
		<description><![CDATA[Super-segue I&#8217;d like to take you on for no reason, other than to help you understand what its like to be me some times&#8230;
Just read &#8220;Programming and fallacies&#8221; on Michael Galpin&#8217;s blog.
Made me think of the very (very, very) old &#8220;Love is a Fallacy&#8221; humor writing by Dobie Gillis (book) author Max Shulman (&#8211; please [...]]]></description>
			<content:encoded><![CDATA[<p>Super-segue I&#8217;d like to take you on for no reason, other than to help you understand what its like to be me some times&#8230;</p>
<p>Just read &#8220;<a href="http://fupeg.blogspot.com/2010/03/programming-and-fallacies.html">Programming and fallacies</a>&#8221; on Michael Galpin&#8217;s blog.</p>
<p>Made me think of the very (very, very) old &#8220;<a href="http://www.blumenfeld-maso.com/dobie-gillis-love-is-a-fallacy/">Love is a Fallacy</a>&#8221; humor writing by Dobie Gillis (book) author <a href="http://en.wikipedia.org/wiki/Max_Shulman">Max Shulman</a> (&#8211; please read that some time, its such a riot). And when I say &#8220;old&#8221; I mean the original story was old when the old black-and-white <a href="http://en.wikipedia.org/wiki/Dobie_Gillis">Dobie Gillis TV show</a> was on. In case you aren&#8217;t familiar, that was the show that launched the career of <a href="http://en.wikipedia.org/wiki/Gilligan%27s_Island">&#8220;Gilligan&#8217;s Island&#8221;</a>&#8217;s Gilligan star <a href="http://www.imdb.com/name/nm0001134/">Bob Denver</a> <em>before</em> Gilligan.</p>
<p>But my segue-adled mind doesn&#8217;t stop there, because Dobie Gillis is no doubt the best example of modern humor a logical mind can ever read. And who defined modern humor? No shit: <a href="http://en.wikipedia.org/wiki/Sigmund_Freud">Freud</a>. You probably didn&#8217;t know he wasn&#8217;t famous in his early career <strong><em>not</em></strong> for his <a href="http://en.wikipedia.org/wiki/Libido">mommy-mangled psycho-sexual</a> theories &#8212; his <a href="http://en.wikipedia.org/wiki/Humour_in_Freud">PhD thesis in fact was the seminal text on laughter and humor</a>.</p>
<p>That I know all those bizarrely ancient pop cultural references, and you don&#8217;t,  means that</p>
<ol>
<li>I am cooler than you;</li>
<li>I need more focused entertainment on Friday nights; and</li>
<li>you don&#8217;t need to worry about competing with me because my brain is constantly routed down these fruitless tracts.</li>
</ol>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F03%2Flogic-fallacy-and-dobie-gillis%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F03%2Flogic-fallacy-and-dobie-gillis%2F&amp;source=bmaso&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.blumenfeld-maso.com/2010/03/logic-fallacy-and-dobie-gillis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>REST-style URIs as Functional Futures</title>
		<link>http://www.blumenfeld-maso.com/2010/03/rest-style-uris-as-functional-futures/</link>
		<comments>http://www.blumenfeld-maso.com/2010/03/rest-style-uris-as-functional-futures/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 17:18:56 +0000</pubDate>
		<dc:creator>Brian Maso</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[futures]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://www.blumenfeld-maso.com/?p=136</guid>
		<description><![CDATA[I&#8217;m laboring under an extremely waterfall project right now. A client asked for a set of REST-style services, but the client&#8217;s making me write approx. 200 pages of documentation before writing the code.
(Most of the documentation could be replaced by a far smaller, and more logically accurate, Operation State Modeling description. But that&#8217;s not what [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m laboring under an extremely <a href="http://en.wikipedia.org/wiki/Waterfall_model">waterfall</a> project right now. A client asked for a set of REST-style services, but the client&#8217;s making me write approx. 200 pages of documentation <em>before</em> writing the code.</p>
<p>(Most of the documentation could be replaced by a far smaller, and more logically accurate, <a href="http://www.ibm.com/developerworks/webservices/library/ar-sosmod/index.html?ca=drs-">Operation State Modeling</a> description. But that&#8217;s not what I&#8217;m here to talk about&#8230;)</p>
<p>Writing the REST-style interface, something pretty interesting occurred to me. I&#8217;ll need the casual reader to put on his thinking cap before moving on here, so please do that if you haven&#8217;t already. I&#8217;ll wait&#8230;</p>
<h2>What is a Future?</h2>
<p>Let&#8217;s start with what a <a href="http://www.ps.uni-saarland.de/alice/manual/futures.html"><em>future</em></a> is: To review, as the linked document says, a <em>future</em> is &#8220;&#8230;a place-holder for the undetermined result of a (concurrent) computation&#8230;&#8221;. Let&#8217;s say there&#8217;s a value your program needs, but the computation or retrieval of that value takes a significant amount of time or resources. Instead of synchronizing (waiting) for the value to be computed, you could spin off an asynchronous process to compute/retrieve the value; alternatively, you could leave a placeholder object that only starts the complex computation/retrieval on demand. Either way, your program leaves in place a placeholder object know as a <em>future</em>.</p>
<p>When your program eventually comes back to the future object asking for the value, the the future either a) hands it back immediately if it has a cached copy; or b) the main program synchronizes (blocks) until the background process completes its computation/retrieval.</p>
<p>The object graph produced by Hibernate when you make an object query uses futures to represent unretrieved values. The query result Hibernate produces is an object graph with placeholder Collections representing lazy relationships. The lazy collections initially don&#8217;t have any data in them, but instead have just enough data in them to generate a secondary Hibernate query. When the program tries to access a lazy collection&#8217;s contents, only then does the Collection query a Hibernate entity manager for the collection of related objects it represents. The placeholder Collection objects are thus futures.</p>
<p><a href="http://www.blumenfeld-maso.com/wp-content/uploads/2010/03/Images_for_URL_as_Future_Post-e1268833802120.jpg"><img class="aligncenter size-full wp-image-142" title="Hibernate Lazy Collections as Futures" src="http://www.blumenfeld-maso.com/wp-content/uploads/2010/03/Images_for_URL_as_Future_Post-e1268833802120.jpg" alt="" width="548" height="412" /></a></p>
<h2>URL/URI References as Lazy Futures</h2>
<p>When a REST-style service response contains a link URL/URI reference to another entity, you can think of that link as a kind of future in the same way as a Hibernate lazily populated Collection. One could easily populate a graph of objects from JSON source, replacing URL/URI references with lazy future objects.</p>
<p>In Scala, a Future[X] extends Function1[X], meaning that Future is Function subtype, so you can use a Function1[_] type to represent URL/URI-based references:</p>
<div id="wpshdo_3" class="wp-synhighlighter-outer"><div id="wpshdt_3" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_3"></a><a id="wpshat_3" class="wp-synhighlighter-title" href="#codesyntax_3"  onClick="javascript:wpsh_toggleBlock(3)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_3" onClick="javascript:wpsh_code(3)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_print(3)" title="Print code"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_about(3)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_3" class="wp-synhighlighter-inner" style="display: block;"><pre class="pascal" style="font-family:monospace;"><span class="sy0">/**</span>
 <span class="sy0">*</span> Invoice can be deserialized from JSON such as<span class="sy0">:</span>
 <span class="sy0">*</span> <span class="coMULTI">{
 *   id: &quot;XYZ&quot;,
 *   lineItems: &quot;http://somewhere.com/inv/XYZ/lineItems&quot;
 *       //      ^^^ URL; serialized representation of
 *       //          a List[LineItem] future.
 * }</span>
 <span class="sy0">**/</span>
class Invoice<span class="br0">&#40;</span>val id<span class="sy0">:</span> <span class="kw4">String</span><span class="sy0">,</span>
              val lineItems<span class="sy0">:</span> <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">=</span>&gt; List<span class="br0">&#91;</span>LineItem<span class="br0">&#93;</span><span class="sy0">,</span>
              ...<span class="br0">&#41;</span> <span class="coMULTI">{
  ...
}</span></pre></div></div>
<p><a href="http://www.blumenfeld-maso.com/wp-content/uploads/2010/03/Images_for_URL_as_Future_Post-1-e1268845847894.jpg"><img class="aligncenter size-full wp-image-148" title="REST URL/URI References as Futures" src="http://www.blumenfeld-maso.com/wp-content/uploads/2010/03/Images_for_URL_as_Future_Post-1-e1268845847894.jpg" alt="" width="550" height="412" /></a>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F03%2Frest-style-uris-as-functional-futures%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F03%2Frest-style-uris-as-functional-futures%2F&amp;source=bmaso&amp;style=normal&amp;service=bit.ly&amp;hashtags=futures,REST,scala" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.blumenfeld-maso.com/2010/03/rest-style-uris-as-functional-futures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GQuery = GWT + jQuery</title>
		<link>http://www.blumenfeld-maso.com/2010/03/gquery-gwt-jquery/</link>
		<comments>http://www.blumenfeld-maso.com/2010/03/gquery-gwt-jquery/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 01:18:40 +0000</pubDate>
		<dc:creator>Brian Maso</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[gwt]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.blumenfeld-maso.com/?p=129</guid>
		<description><![CDATA[From Timefire:
First, let&#8217;s just dispense with the details and show you a working example, yes, this is working code:


If you haven&#8217;t seen that before, and if the left side of you brain didn&#8217;t just rupture the coronal suture between the frontal and parietal bones of your skull, then get find an absorbent mop and read [...]]]></description>
			<content:encoded><![CDATA[<p>From <a href="http://timepedia.blogspot.com/2008/04/gwt-road-to-15-language-features-and.html">Timefire</a>:</p>
<blockquote><p>First, let&#8217;s just dispense with the details and show you a working example, yes, this is working code:</p>
<pre><div id="wpshdo_4" class="wp-synhighlighter-outer"><div id="wpshdt_4" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_4"></a><a id="wpshat_4" class="wp-synhighlighter-title" href="#codesyntax_4"  onClick="javascript:wpsh_toggleBlock(4)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_4" onClick="javascript:wpsh_code(4)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_4" onClick="javascript:wpsh_print(4)" title="Print code"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_4" onClick="javascript:wpsh_about(4)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_4" class="wp-synhighlighter-inner" style="display: block;"><pre class="pascal" style="font-family:monospace;"><span class="kw1">public</span> void onModuleLoad<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="coMULTI">{
    $(&quot;div&quot;).css(&quot;color&quot;, &quot;red&quot;).click(new Function() {
      public void f(Element e) {
        Window.alert(&quot;Hello&quot;);
        $(e).as(Effects).fadeOut();
      }</span>
    <span class="br0">&#125;</span><span class="br0">&#41;</span>;
  <span class="br0">&#125;</span></pre></div></div></pre>
</blockquote>
<p>If you haven&#8217;t seen that before, and if the left side of you brain didn&#8217;t just rupture the coronal suture between the frontal and parietal bones of your skull, then get find an absorbent mop and read it again.</p>
<p>Inheriting and using GQuery is as easy as importing in to your module. Of course you need to download and build GQuery, then try it out!</p>
<div id="wpshdo_5" class="wp-synhighlighter-outer"><div id="wpshdt_5" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_5"></a><a id="wpshat_5" class="wp-synhighlighter-title" href="#codesyntax_5"  onClick="javascript:wpsh_toggleBlock(5)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_5" onClick="javascript:wpsh_code(5)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_5" onClick="javascript:wpsh_print(5)" title="Print code"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_5" onClick="javascript:wpsh_about(5)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_5" class="wp-synhighlighter-inner" style="display: block;"><pre class="pascal" style="font-family:monospace;">&lt;module ...&gt;
  &lt;inherits <span class="kw1">name</span><span class="sy0">=</span><span class="st_h">'com.google.gwt.query.Query'</span><span class="sy0">/</span>&gt;
  ...
&lt;<span class="sy0">/</span>module&gt;</pre></div></div>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F03%2Fgquery-gwt-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F03%2Fgquery-gwt-jquery%2F&amp;source=bmaso&amp;style=normal&amp;service=bit.ly&amp;hashtags=gwt,jquery" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.blumenfeld-maso.com/2010/03/gquery-gwt-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Back by Popular Demand: Another Week of GWT 2.0 Training</title>
		<link>http://www.blumenfeld-maso.com/2010/01/back-by-popular-demand-another-week-of-gwt-2-0-training/</link>
		<comments>http://www.blumenfeld-maso.com/2010/01/back-by-popular-demand-another-week-of-gwt-2-0-training/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 13:57:09 +0000</pubDate>
		<dc:creator>Brian Maso</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blumenfeld-maso.com/?p=108</guid>
		<description><![CDATA[Response to last week&#8217;s GWT 2.0 training was pretty enthusiastic! So much so, that we&#8217;re running another week of training: 2.2.2010 through 2.5.2010. If anyone is interested in joining us in Irvine, for all or just part of the time, please contact me (@bmaso on twitter, or use the contact form). We can offer some [...]]]></description>
			<content:encoded><![CDATA[<p>Response to <a href="http://www.blumenfeld-maso.com/2010/01/jan-25-2010-gwt-training-with-brian-maso/">last week&#8217;s GWT 2.0 training</a> was pretty enthusiastic! So much so, that we&#8217;re running another week of training: 2.2.2010 through 2.5.2010. If anyone is interested in joining us in Irvine, for all or just part of the time, please contact me (<a href="http://twitter.com/bmaso">@bmaso on twitter</a>, or use <a href="http://www.blumenfeld-maso.com/contact-us">the contact form</a>). We can offer some pretty good prices for the remaining last-minute seats!</p>
<p>In addition to normal GWT, here&#8217;s the super cool topics we&#8217;ll be covering:</p>
<ul>
<li><strong>Code splitting</strong> &#8212; dynamically download different parts of the GWT app for efficiency</li>
<li><strong>GWT integration with poplar toolkits</strong> (e.g., jQuery, ExtJS, etc.) through JSNI</li>
<li><strong>Code generators</strong> and <strong>resource generators</strong></li>
<li><strong>Mashups</strong> and <strong>cool service integrations</strong></li>
<li>Lots more!</li>
</ul>
<p>This course is especially good for J2EE developers who don&#8217;t feel completely (or even at all) comfortable in JavaScript or the browser environment &#8212; you will end your time with us with some amazing &#8220;<em>Browser Fu</em>&#8220;!
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F01%2Fback-by-popular-demand-another-week-of-gwt-2-0-training%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F01%2Fback-by-popular-demand-another-week-of-gwt-2-0-training%2F&amp;source=bmaso&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.blumenfeld-maso.com/2010/01/back-by-popular-demand-another-week-of-gwt-2-0-training/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Scala Word of the Day: For Loops (All 4 Kinds!)</title>
		<link>http://www.blumenfeld-maso.com/2010/01/scala-word-of-the-day-for-loops-all-4-kinds/</link>
		<comments>http://www.blumenfeld-maso.com/2010/01/scala-word-of-the-day-for-loops-all-4-kinds/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 06:36:54 +0000</pubDate>
		<dc:creator>Brian Maso</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scala Word of the Day]]></category>
		<category><![CDATA[for loop]]></category>
		<category><![CDATA[iterable]]></category>
		<category><![CDATA[iterator]]></category>
		<category><![CDATA[non-strict]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://www.blumenfeld-maso.com/?p=90</guid>
		<description><![CDATA[You think you know how to define a for loop, do you? Scala has 4 different kinds.
1. Traditional for loop. Loops through the members of an Iteratable. The result of the loop block is Unit.
Not surprisingly, this loop prints out the members of the collection, in order that they are returned by the collection&#8217;s iterator. [...]]]></description>
			<content:encoded><![CDATA[<p>You think you know how to define a <em>for loop</em>, do you? Scala has <em><strong>4</strong></em> different kinds.</p>
<hr />1. <strong>Traditional for loop</strong>. Loops through the members of an Iteratable. The result of the loop block is <code>Unit</code>.</p>
<div id="wpshdo_6" class="wp-synhighlighter-outer"><div id="wpshdt_6" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_6"></a><a id="wpshat_6" class="wp-synhighlighter-title" href="#codesyntax_6"  onClick="javascript:wpsh_toggleBlock(6)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_6" onClick="javascript:wpsh_code(6)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_6" onClick="javascript:wpsh_print(6)" title="Print code"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_6" onClick="javascript:wpsh_about(6)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_6" class="wp-synhighlighter-inner" style="display: block;"><pre class="pascal" style="font-family:monospace;"><span class="kw1">for</span><span class="br0">&#40;</span>mbr &lt;<span class="sy0">-</span> collection<span class="br0">&#41;</span> <span class="coMULTI">{
  println(mbr)
}</span></pre></div></div>
<p>Not surprisingly, this loop prints out the members of the collection, in order that they are returned by the collection&#8217;s iterator. In fact, this loop construct is translated exactly to</p>
<div id="wpshdo_7" class="wp-synhighlighter-outer"><div id="wpshdt_7" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_7"></a><a id="wpshat_7" class="wp-synhighlighter-title" href="#codesyntax_7"  onClick="javascript:wpsh_toggleBlock(7)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_7" onClick="javascript:wpsh_code(7)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_7" onClick="javascript:wpsh_print(7)" title="Print code"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_7" onClick="javascript:wpsh_about(7)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_7" class="wp-synhighlighter-inner" style="display: block;"><pre class="pascal" style="font-family:monospace;">collection.<span class="me1">foreach</span><span class="br0">&#40;</span>mbr <span class="sy0">=</span>&gt; println<span class="br0">&#40;</span>mbr<span class="br0">&#41;</span><span class="br0">&#41;</span></pre></div></div>
<hr />2. <strong>For&#8230;Yield Loop</strong>. Use the yield keyword within the body of a for loop. The loop block has a result which is an iterator of the yielded results. Thus the for loop can act as the RHS of an assignment.</p>
<div id="wpshdo_8" class="wp-synhighlighter-outer"><div id="wpshdt_8" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_8"></a><a id="wpshat_8" class="wp-synhighlighter-title" href="#codesyntax_8"  onClick="javascript:wpsh_toggleBlock(8)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_8" onClick="javascript:wpsh_code(8)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_8" onClick="javascript:wpsh_print(8)" title="Print code"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_8" onClick="javascript:wpsh_about(8)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_8" class="wp-synhighlighter-inner" style="display: block;"><pre class="pascal" style="font-family:monospace;">val transformed <span class="sy0">=</span> <span class="kw1">for</span><span class="br0">&#40;</span>mbr &lt;<span class="sy0">-</span> collection<span class="br0">&#41;</span> <span class="coMULTI">{
  yield transform(mbr)
}</span></pre></div></div>
<p>Each time through this example loop, the result of the loop is yielded out. All the yielded results are collected in to a single iterator. This type of for loop is syntactic sugar for the following statement</p>
<div id="wpshdo_9" class="wp-synhighlighter-outer"><div id="wpshdt_9" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_9"></a><a id="wpshat_9" class="wp-synhighlighter-title" href="#codesyntax_9"  onClick="javascript:wpsh_toggleBlock(9)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_9" onClick="javascript:wpsh_code(9)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_9" onClick="javascript:wpsh_print(9)" title="Print code"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_9" onClick="javascript:wpsh_about(9)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_9" class="wp-synhighlighter-inner" style="display: block;"><pre class="pascal" style="font-family:monospace;">val transformed <span class="sy0">=</span> collection.<span class="me1">map</span><span class="br0">&#40;</span>mbr <span class="sy0">=</span>&gt; transform<span class="br0">&#40;</span>mbr<span class="br0">&#41;</span><span class="br0">&#41;</span></pre></div></div>
<p>That&#8217;s right, a simple for&#8230;yield loop is just syntactic sugar for <code>Iteratable.map()</code>.</p>
<hr /><strong>Interlude: Watch Out for Infinite Iterables</strong></p>
<p>Infinite (or extremely large) iterables, usually implemented as <code>Stream</code>s or <code>Range</code>s, are a bit tricky. For example, it probably wouldn&#8217;t surprise you to learn that the following traditional for loop will not terminate (at least not in your lifetime):</p>
<div id="wpshdo_10" class="wp-synhighlighter-outer"><div id="wpshdt_10" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_10"></a><a id="wpshat_10" class="wp-synhighlighter-title" href="#codesyntax_10"  onClick="javascript:wpsh_toggleBlock(10)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_10" onClick="javascript:wpsh_code(10)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_10" onClick="javascript:wpsh_print(10)" title="Print code"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_10" onClick="javascript:wpsh_about(10)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_10" class="wp-synhighlighter-inner" style="display: block;"><pre class="pascal" style="font-family:monospace;"><span class="kw1">for</span><span class="br0">&#40;</span>i &lt;<span class="sy0">-</span> 0 <span class="kw1">to</span> <span class="nu0">100000000000</span><span class="br0">&#41;</span> println<span class="br0">&#40;</span>i<span class="br0">&#41;</span></pre></div></div>
<p>But executing this next for&#8230;yield loop does <em>not</em> cause an indefinite wait &#8212; it works fine! (Go ahead, try it out!)</p>
<div id="wpshdo_11" class="wp-synhighlighter-outer"><div id="wpshdt_11" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_11"></a><a id="wpshat_11" class="wp-synhighlighter-title" href="#codesyntax_11"  onClick="javascript:wpsh_toggleBlock(11)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_11" onClick="javascript:wpsh_code(11)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_11" onClick="javascript:wpsh_print(11)" title="Print code"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_11" onClick="javascript:wpsh_about(11)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_11" class="wp-synhighlighter-inner" style="display: block;"><pre class="pascal" style="font-family:monospace;">val numberStrings <span class="sy0">=</span> <span class="kw1">for</span><span class="br0">&#40;</span>i &lt;<span class="sy0">-</span> 0 <span class="kw1">to</span> <span class="nu0">100000000000</span><span class="br0">&#41;</span> yield <span class="br0">&#40;</span><span class="st0">&quot;&quot;</span> <span class="sy0">+</span> i<span class="br0">&#41;</span></pre></div></div>
<p>How can this be so? You need to know that <code>o to 10000000000</code> results in a <code>Range</code> object, which is a non-strict iterator. That is, it is an iterator that calculates the &#8220;next&#8221; value as you iterate through it, rather than pre-computing all members up front and storing them in memory when the <code>Range</code> is created.</p>
<p>Iteratable functions that yield a scalar result, like <code>foldLeft()</code> or <code>length()</code> or any <a href="http://www.blumenfeld-maso.com/2010/01/scala-word-of-the-day-catamorphism/">catamorphic function</a>, are not safe to use with non-strict iterators, because these methods must iterate over the entire iteratable&#8217;s contents to produce a result. The <code>foreach()</code> method falls in to this unsafe category &#8212; <code>foreach()</code>&#8217;s return type is Unit, which is considered scalar.</p>
<p>Remember the traditional for loop is just syntactic sugar for a <code>foreach()</code> call, and this explains why looping over the range with a traditional loop causes an indefinite wait.</p>
<p>Iteratable functions that yield results of similar size to the input, such as <code>map()</code> and <code>flatMap()</code>, are perfectly safe to use with non-strict iterators. These methods themselves yield non-strict iterators, and don&#8217;t need to iterate over the source iterator&#8217;s contents to yield a result.</p>
<p>The for&#8230;yield loop is just syntactic sugar for a <code>map()</code> call, and this explains why looping over the <code>Range</code> with a for&#8230;yield loop doesn&#8217;t cause an indefinite wait.</p>
<p><strong>End of Interlude</strong></p>
<hr />3. <strong>Guarded For&#8230;Yield Loop</strong>. Throw an <em>if</em> guard in to a for..yield loop, and its translated to a filter-map pipeline (perhaps I should say filter |&gt; map, using <a href="http://www.blumenfeld-maso.com/2009/10/pipe-operator-for-scala/">the pipe operator</a>).</p>
<div id="wpshdo_12" class="wp-synhighlighter-outer"><div id="wpshdt_12" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_12"></a><a id="wpshat_12" class="wp-synhighlighter-title" href="#codesyntax_12"  onClick="javascript:wpsh_toggleBlock(12)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_12" onClick="javascript:wpsh_code(12)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_12" onClick="javascript:wpsh_print(12)" title="Print code"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_12" onClick="javascript:wpsh_about(12)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_12" class="wp-synhighlighter-inner" style="display: block;"><pre class="pascal" style="font-family:monospace;"><span class="co1">// Using the guarded for...yield loop syntactic sugar</span>
val oddSquares <span class="sy0">=</span>
  <span class="kw1">for</span><span class="br0">&#40;</span>i &lt;<span class="sy0">-</span> 0 <span class="kw1">to</span> 10000000000 <span class="kw1">if</span> i % <span class="nu0">2</span> <span class="sy0">==</span> <span class="nu0">1</span><span class="br0">&#41;</span> yield <span class="br0">&#40;</span>i<span class="sy0">*</span>i<span class="br0">&#41;</span>
&nbsp;
<span class="co1">// Exactly the same thing as</span>
val oddSquares <span class="sy0">=</span> <span class="br0">&#40;</span>0 <span class="kw1">to</span> <span class="nu0">10000000000</span><span class="br0">&#41;</span>.<span class="me1">filter</span><span class="br0">&#40;</span>i<span class="sy0">=</span>&gt;i % <span class="nu0">2</span> <span class="sy0">==</span> <span class="nu0">1</span><span class="br0">&#41;</span>.<span class="me1">map</span><span class="br0">&#40;</span>i<span class="sy0">=</span>&gt;i<span class="sy0">*</span>i<span class="br0">&#41;</span></pre></div></div>
<p>And as the example implies, this for loop style is non-strict collection safe (because both <code>filter()</code> and <code>map()</code> are non-strict safe).</p>
<hr />4. <strong>Nested For Loop</strong>. Nesting iteration over iterators is syntactic sugar for a nested <code>flatMap()</code> call. Stare at the loop below and the form it gets translated in to by the Scala compiler for a little bit, you don&#8217;t need my explanation:</p>
<div id="wpshdo_13" class="wp-synhighlighter-outer"><div id="wpshdt_13" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_13"></a><a id="wpshat_13" class="wp-synhighlighter-title" href="#codesyntax_13"  onClick="javascript:wpsh_toggleBlock(13)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_13" onClick="javascript:wpsh_code(13)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_13" onClick="javascript:wpsh_print(13)" title="Print code"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_13" onClick="javascript:wpsh_about(13)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_13" class="wp-synhighlighter-inner" style="display: block;"><pre class="pascal" style="font-family:monospace;"><span class="co1">// Long-winded nested for loop</span>
val pairsThatSumTo100 <span class="sy0">=</span>
  <span class="kw1">for</span><span class="br0">&#40;</span>i &lt;<span class="sy0">-</span> 0 <span class="kw1">to</span> <span class="nu0">100</span>;
      j &lt;<span class="sy0">-</span> i <span class="kw1">to</span> 100 <span class="kw1">if</span> i <span class="sy0">+</span> j <span class="sy0">==</span> <span class="nu0">100</span><span class="br0">&#41;</span>
    yield Pair<span class="br0">&#40;</span>i<span class="sy0">,</span> j<span class="br0">&#41;</span>
&nbsp;
<span class="co1">// Slightly shorter but harder to read raw form that gets compiled</span>
val pairsThatSumTo100 <span class="sy0">=</span>
  <span class="br0">&#40;</span>0 <span class="kw1">to</span> 100<span class="br0">&#41;</span>.<span class="me1">flatMap</span><span class="br0">&#40;</span>i<span class="sy0">=</span>&gt;<span class="br0">&#40;</span>i <span class="kw1">to</span> <span class="nu0">100</span><span class="br0">&#41;</span>.<span class="me1">filter</span><span class="br0">&#40;</span>j<span class="sy0">=</span>&gt;i<span class="sy0">+</span>j<span class="sy0">==</span><span class="nu0">100</span><span class="br0">&#41;</span>.<span class="me1">map</span><span class="br0">&#40;</span>j<span class="sy0">=</span>&gt;Pair<span class="br0">&#40;</span>i<span class="sy0">,</span>j<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></pre></div></div>
<p>Note that nested for loops are also non-strict safe, because <code>filter()</code>, <code>map()</code> and <code>flatMap()</code> are all non-strict safe. Only the traditional for loop is not safe for non-strict use.
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F01%2Fscala-word-of-the-day-for-loops-all-4-kinds%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F01%2Fscala-word-of-the-day-for-loops-all-4-kinds%2F&amp;source=bmaso&amp;style=normal&amp;service=bit.ly&amp;hashtags=for+loop,iterable,iterator,non-strict,scala" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.blumenfeld-maso.com/2010/01/scala-word-of-the-day-for-loops-all-4-kinds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scala Word of the Day: Catamorphism</title>
		<link>http://www.blumenfeld-maso.com/2010/01/scala-word-of-the-day-catamorphism/</link>
		<comments>http://www.blumenfeld-maso.com/2010/01/scala-word-of-the-day-catamorphism/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 04:31:27 +0000</pubDate>
		<dc:creator>Brian Maso</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scala Word of the Day]]></category>

		<guid isPermaLink="false">http://www.blumenfeld-maso.com/?p=75</guid>
		<description><![CDATA[Catamorphism is the $20 word for a function that condenses a set of values down to a single value. For example, in SQL the terms grouping function or aggregator function refer to catamorphic functions, which includes SQL functions AVERAGE(), SUM(), and MEDIAN(). All of these SQL functions have in common a pattern that operates on [...]]]></description>
			<content:encoded><![CDATA[<p><strong><em>Catamorphism</em></strong> is the $20 word for a function that condenses a set of values down to a single value. For example, in SQL the terms <em>grouping function</em> or <em>aggregator function</em> refer to catamorphic functions, which includes SQL functions <code>AVERAGE()</code>, <code>SUM()</code>, and <code>MEDIAN()</code>. All of these SQL functions have in common a pattern that operates on a set of numeric values, and returns a single numeric value.</p>
<p>In functional programming, catamorphisms are embodied in the <em>folds</em> functions. I like Scala, so I&#8217;ll discuss some catamorphic function examples in found in the standard Scala library&#8217;s Iterable trait.</p>
<p>The Iterable trait in Scala represents the concept of an ordered series of same-typed values. This trait is common to all the collection types (Lists, Seqs, and Streams, and many other &#8220;series like&#8221; things). The Iterable trait defines several catamorphic functions &#8212; functions which reduce the series of values down to a single value.</p>
<p>Perhaps the simplest to start with is the <code>forall()</code> and <code>exists()</code> methods. These methods each take a Boolean test operation, applies it to each member of the Iterable, and returns the logical AND (<code>forall()</code>), or OR (<code>exists</code>) of the test values. Despite the fact that they act differently, both methods have the same type signature, because both are Boolean catamorphisms:</p>
<div id="wpshdo_14" class="wp-synhighlighter-outer"><div id="wpshdt_14" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_14"></a><a id="wpshat_14" class="wp-synhighlighter-title" href="#codesyntax_14"  onClick="javascript:wpsh_toggleBlock(14)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_14" onClick="javascript:wpsh_code(14)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_14" onClick="javascript:wpsh_print(14)" title="Print code"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_14" onClick="javascript:wpsh_about(14)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_14" class="wp-synhighlighter-inner" style="display: block;"><pre class="scala" style="font-family:monospace;"><a href="http://scala-lang.org"><span class="kw1">trait</span></a> Iterable<span class="br0">&#91;</span>A<span class="br0">&#93;</span> <span class="br0">&#123;</span>
  ...
  <a href="http://scala-lang.org"><span class="kw1">def</span></a> forall<span class="br0">&#40;</span>test<span class="sy0">:</span> <span class="br0">&#40;</span>A<span class="br0">&#41;</span> <span class="sy0">=&gt;</span> Boolean<span class="br0">&#41;</span><span class="sy0">:</span> Boolean <span class="sy0">=</span> ...
  <a href="http://scala-lang.org"><span class="kw1">def</span></a> find<span class="br0">&#40;</span>test<span class="sy0">:</span> <span class="br0">&#40;</span>A<span class="br0">&#41;</span> <span class="sy0">=&gt;</span> Boolean<span class="br0">&#41;</span><span class="sy0">:</span> Boolean <span class="sy0">=</span> ...
  ...
<span class="br0">&#125;</span></pre></div></div>
<p>Event more generic are the <code>foldLeft()</code> and <code>foldRight()</code> methods in Iterable. <code>foldRight()</code> is really just a slight tweak on <code>foldLeft()</code>, so I&#8217;ll just explain left-hand version and for the right-hand version I&#8217;ll just do some&#8230; erm&#8230; hand-waving.</p>
<p>The <code>foldLeft()</code> method receives an aggregator function used to combine each member of the Iterable successively in to an aggregated value. <code>foldLeft()</code> starts with an initial value, which it combines with the first Iterable value using the aggregator function. The result is then aggregated with the second Iterable value; and then the third, and so on, until the entire Iterable has been reduce down to a single aggregated value. Thus <code>foldLeft()</code> is a catamorphism, as it combines and reduces the series of values represented by an Iterable down to a single value.</p>
<p style="text-align: center;"><img class="aligncenter" title="fodlLeft Sequence Diagram" src="http://www.websequencediagrams.com/cgi-bin/cdraw?lz=Q2xpZW50IENvZGUtPmZvbGRMZWZ0OgoAAggtPmluaXRpYWxWYWx1ZTogYSA8LSBnZXQgdmFsdWUKbG9vcAogICAgACYKSXRlcmFibGU6IG4AJQdOZXh0ABYPYWdncmVnYXRvckZ1bmMAUAdjb21iaW5lKGEsIG4pCmVuZAB7CwCBHAs6IHJldHVybmVkAIB_BiA8LSBh&amp;s=default" alt="" width="512" height="214" /></p>
<p><code>foldRight()</code> is the same as <code>foldLeft()</code> &#8212; the only difference being which end of the series each starts with. The <code>foldLeft()</code> function starts with the head of the series (traditionally drawn to the left of the tail &#8212; hence the name) and proceeds to the coda; <code>foldRight()</code> starts with the series coda and proceeds to the head.</p>
<div id="wpshdo_15" class="wp-synhighlighter-outer"><div id="wpshdt_15" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_15"></a><a id="wpshat_15" class="wp-synhighlighter-title" href="#codesyntax_15"  onClick="javascript:wpsh_toggleBlock(15)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_15" onClick="javascript:wpsh_code(15)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_15" onClick="javascript:wpsh_print(15)" title="Print code"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_15" onClick="javascript:wpsh_about(15)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_15" class="wp-synhighlighter-inner" style="display: block;"><pre class="scala" style="font-family:monospace;"><a href="http://scala-lang.org"><span class="kw1">trait</span></a> Iterable<span class="br0">&#91;</span>A<span class="br0">&#93;</span> <span class="br0">&#123;</span>
  ...
  <a href="http://scala-lang.org"><span class="kw1">def</span></a> foldLeft<span class="br0">&#91;</span>B<span class="br0">&#93;</span> <span class="br0">&#40;</span>initialValue<span class="sy0">:</span> B<span class="br0">&#41;</span><span class="br0">&#40;</span>aggregatorFunc<span class="sy0">:</span> <span class="br0">&#40;</span>B, A<span class="br0">&#41;</span> <span class="sy0">=&gt;</span> B<span class="br0">&#41;</span><span class="sy0">:</span> B <span class="sy0">=</span> ...
  <a href="http://scala-lang.org"><span class="kw1">def</span></a> foldRight<span class="br0">&#91;</span>B<span class="br0">&#93;</span><span class="br0">&#40;</span>initialValue<span class="sy0">:</span> B<span class="br0">&#41;</span><span class="br0">&#40;</span>aggregatorFunc<span class="sy0">:</span> <span class="br0">&#40;</span>B, A<span class="br0">&#41;</span> <span class="sy0">=&gt;</span> B<span class="br0">&#41;</span><span class="sy0">:</span> B <span class="sy0">=</span> ...
  ...
<span class="br0">&#125;</span></pre></div></div>
<p>If you think for a second, you can see how <code>forall()</code> and <code>exists()</code> could be implemented using <code>foldLeft()</code>:</p>
<div id="wpshdo_16" class="wp-synhighlighter-outer"><div id="wpshdt_16" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_16"></a><a id="wpshat_16" class="wp-synhighlighter-title" href="#codesyntax_16"  onClick="javascript:wpsh_toggleBlock(16)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_16" onClick="javascript:wpsh_code(16)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_16" onClick="javascript:wpsh_print(16)" title="Print code"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_16" onClick="javascript:wpsh_about(16)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_16" class="wp-synhighlighter-inner" style="display: block;"><pre class="scala" style="font-family:monospace;"><a href="http://scala-lang.org"><span class="kw1">trait</span></a> Iterable<span class="br0">&#91;</span>A<span class="br0">&#93;</span> <span class="br0">&#123;</span>
  ...
  <a href="http://scala-lang.org"><span class="kw1">def</span></a> foldLeft<span class="br0">&#91;</span>B<span class="br0">&#93;</span> <span class="br0">&#40;</span>initialValue<span class="sy0">:</span> B<span class="br0">&#41;</span><span class="br0">&#40;</span>aggregatorFunc<span class="sy0">:</span> <span class="br0">&#40;</span>B, A<span class="br0">&#41;</span> <span class="sy0">=&gt;</span> B<span class="br0">&#41;</span><span class="sy0">:</span> B <span class="sy0">=</span> ...
  ...
  <a href="http://scala-lang.org"><span class="kw1">def</span></a> forall<span class="br0">&#40;</span>test<span class="sy0">:</span> <span class="br0">&#40;</span>A<span class="br0">&#41;</span> <span class="sy0">=&gt;</span> Boolean<span class="br0">&#41;</span><span class="sy0">:</span> Boolean <span class="sy0">=</span>
      foldLeft<span class="br0">&#40;</span><a href="http://scala-lang.org"><span class="kw1">true</span></a><span class="br0">&#41;</span><span class="br0">&#40;</span><span class="sy0">_</span> <span class="sy0">&amp;&amp;</span> test<span class="br0">&#40;</span><span class="sy0">_</span><span class="br0">&#41;</span><span class="br0">&#41;</span>
&nbsp;
  <a href="http://scala-lang.org"><span class="kw1">def</span></a> exists<span class="br0">&#40;</span>test<span class="sy0">:</span> <span class="br0">&#40;</span>A<span class="br0">&#41;</span> <span class="sy0">=&gt;</span> Boolean<span class="br0">&#41;</span><span class="sy0">:</span> Boolean <span class="sy0">=</span>
      foldLeft<span class="br0">&#40;</span><a href="http://scala-lang.org"><span class="kw1">false</span></a><span class="br0">&#41;</span><span class="br0">&#40;</span><span class="sy0">_</span> || test<span class="br0">&#40;</span><span class="sy0">_</span><span class="br0">&#41;</span><span class="br0">&#41;</span>
  ...
<span class="br0">&#125;</span></pre></div></div>
<p>In addition to <code>forall()</code> and <code>exists()</code> there are other catamorphic convenience functions in Iterable, and as it turns out each of them could be re-implemented using <code>foldLeft()</code> (or <code>foldRight()</code>) as well. For example, <code>mkString()</code> creates a string representation of the Iterable series by combining each member&#8217;s <code>toString()</code> value, along with a prefix, a suffix, and a list separator string.</p>
<div id="wpshdo_17" class="wp-synhighlighter-outer"><div id="wpshdt_17" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_17"></a><a id="wpshat_17" class="wp-synhighlighter-title" href="#codesyntax_17"  onClick="javascript:wpsh_toggleBlock(17)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_17" onClick="javascript:wpsh_code(17)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_17" onClick="javascript:wpsh_print(17)" title="Print code"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_17" onClick="javascript:wpsh_about(17)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.blumenfeld-maso.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_17" class="wp-synhighlighter-inner" style="display: block;"><pre class="scala" style="font-family:monospace;"><a href="http://scala-lang.org"><span class="kw1">trait</span></a> Iterable<span class="br0">&#91;</span>A<span class="br0">&#93;</span> <span class="br0">&#123;</span>
  ...
  <a href="http://scala-lang.org"><span class="kw1">def</span></a> foldLeft<span class="br0">&#91;</span>B<span class="br0">&#93;</span> <span class="br0">&#40;</span>initialValue<span class="sy0">:</span> B<span class="br0">&#41;</span><span class="br0">&#40;</span>aggregatorFunc<span class="sy0">:</span> <span class="br0">&#40;</span>B, A<span class="br0">&#41;</span> <span class="sy0">=&gt;</span> B<span class="br0">&#41;</span><span class="sy0">:</span> B <span class="sy0">=</span> ...
  ...
  <a href="http://scala-lang.org"><span class="kw1">def</span></a> mkString<span class="br0">&#40;</span>prefix<span class="sy0">:</span> String, separator<span class="sy0">:</span> String, suffix<span class="sy0">:</span> String<span class="br0">&#41;</span><span class="sy0">:</span> String <span class="sy0">=</span>
      foldLeft<span class="br0">&#40;</span>prefix<span class="br0">&#41;</span><span class="br0">&#40;</span><span class="sy0">_</span> + separator + <span class="sy0">_</span><span class="br0">&#41;</span> + suffix
  ...
<span class="br0">&#125;</span></pre></div></div>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F01%2Fscala-word-of-the-day-catamorphism%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F01%2Fscala-word-of-the-day-catamorphism%2F&amp;source=bmaso&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.blumenfeld-maso.com/2010/01/scala-word-of-the-day-catamorphism/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jan.25.2010 GWT Training with Brian Maso</title>
		<link>http://www.blumenfeld-maso.com/2010/01/jan-25-2010-gwt-training-with-brian-maso/</link>
		<comments>http://www.blumenfeld-maso.com/2010/01/jan-25-2010-gwt-training-with-brian-maso/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 06:29:24 +0000</pubDate>
		<dc:creator>Brian Maso</dc:creator>
				<category><![CDATA[Events and Calendar]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.blumenfeld-maso.com/?p=66</guid>
		<description><![CDATA[Follow-up: What a great week! We had a few really sharp students, and were able to discuss and learn about all kind of extra material in addition to the materials in the course outline. It was especially rewarding to see the students&#8217; appreciation of the amazing new features of GWT 2.0 &#8212; Code Splitting, resource [...]]]></description>
			<content:encoded><![CDATA[<p><strong><em>Follow-up: What a great week! We had a few really sharp students, and were able to discuss and learn about all kind of extra material in addition to the materials in the course outline. It was especially rewarding to see the students&#8217; appreciation of the amazing new features of GWT 2.0 &#8212; Code Splitting, resource generators and code generators, and we worked out how to make a GWT Widget/jQuery UI bridge: all in addition to the course materials!<br />
</em></strong></p>
<p>We&#8217;ve published an <a href="jan-25-2010-5-day-gwt-training">in-depth description page</a>, or you can go to visit the <a href="purchase-tickets-to-jan-25-2010-gwt-training">ticket purchasing page</a> right away. <a href="http://code.google.com/webtoolkit/">GWT</a> is an extremely valuable tool to add to your development toolkit. This amazing in-depth instruction will up your personal capitol, and your developer skill-set, quickly!</p>
<p>We&#8217;ve got several open seats of the date of this posting, so we&#8217;re trying something novel to get those seats sold: every day until Jan. 25, the price of each seat is going down by $300! On Jan. 19, the price was $2,000 for all 5 instructional days (normally $3,750). The next day, Jan. 20, the price went down to $1700, and so on.</p>
<p>If there are still seats open on Jan. 25th, they will sell for just $500 for all 5 instructional days!</p>
<p>You can also purchase fewer than 5 days. If you just want a quick instruction to GWT, attend just days 1 and 2. For more in-depth mastery of GWT, attend days 3, 4, or 5! Its up to you to decide how to increase your personal value and abilities as a developer with this unique set-up.</p>
<p>Location, BTW, is at the <a href="http://www.smart-soft.com">Smart-Soft</a> training location in Irvine, CA.
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F01%2Fjan-25-2010-gwt-training-with-brian-maso%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F01%2Fjan-25-2010-gwt-training-with-brian-maso%2F&amp;source=bmaso&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.blumenfeld-maso.com/2010/01/jan-25-2010-gwt-training-with-brian-maso/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;What Does Monad Mean&#8221; by Tony Morris</title>
		<link>http://www.blumenfeld-maso.com/2010/01/what-does-monad-mean-by-tony-morris/</link>
		<comments>http://www.blumenfeld-maso.com/2010/01/what-does-monad-mean-by-tony-morris/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 04:38:24 +0000</pubDate>
		<dc:creator>Brian Maso</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[monad]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.blumenfeld-maso.com/?p=42</guid>
		<description><![CDATA[Like most software professionals, I have had a troubling, shameful secret. I had no idea what monad means. More importantly, I had no idea why I should know what monad means. But I had a sneaking suspicion that I should.
Tony Morris is this incredibly knowledgeable and opinionated (in a good way) CS professor who I [...]]]></description>
			<content:encoded><![CDATA[<p>Like most software professionals, I have had a troubling, shameful secret. I had no idea what <em>monad</em> means. More importantly, I had no idea why I should know what <em>monad</em> means. But I had a sneaking suspicion that I should.</p>
<p><a href="http://tmorris.net/">Tony Morris</a> is this incredibly knowledgeable and opinionated (in a good way) CS professor who I know because of his swaggering around the Scala-Users mailing list. I love Tony because he takes the time to try explain important CS concepts, as in this video.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=8729673&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=8729673&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>The slides in the video are incredibly fuzzy. From Tony&#8217;s website, <a href="http://projects.tmorris.net/public/what-does-monad-mean/artifacts/1.0/chunk-html/index.html">the talk&#8217;s slides</a>.
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F01%2Fwhat-does-monad-mean-by-tony-morris%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.blumenfeld-maso.com%2F2010%2F01%2Fwhat-does-monad-mean-by-tony-morris%2F&amp;source=bmaso&amp;style=normal&amp;service=bit.ly&amp;hashtags=monad,video" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.blumenfeld-maso.com/2010/01/what-does-monad-mean-by-tony-morris/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
