<?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.</title>
	<atom:link href="http://www.blumenfeld-maso.com/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>Sat, 06 Mar 2010 01:18:40 +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>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><div class="wp-synhighlighter-expanded"><a name="#codesyntax1"></a><a style="wp-synhighlighter-title" href="#codesyntax1"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="pascal" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000; font-weight: bold;">public</span> void onModuleLoad<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">{</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">&nbsp;   $(&quot;div&quot;).css(&quot;color&quot;, &quot;red&quot;).click(new Function() {</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">&nbsp;     public void f(Element e) {</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">&nbsp;       Window.alert(&quot;Hello&quot;);</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">&nbsp;       $(e).as(Effects).fadeOut();</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">&nbsp;     }</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">  <span style="color: #009900;">&#125;</span></div></li></ol></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><div class="wp-synhighlighter-expanded"><a name="#codesyntax2"></a><a style="wp-synhighlighter-title" href="#codesyntax2"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="pascal" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&lt;module ...&gt;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">  &lt;inherits <span style="color: #000000; font-weight: bold;">name</span><span style="color: #339933;">=</span><span style="color: #ff0000;">'com.google.gwt.query.Query'</span><span style="color: #339933;">/</span>&gt;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">  ...</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&lt;<span style="color: #339933;">/</span>module&gt;</div></li></ol></pre></div></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;!</p>
]]></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><div class="wp-synhighlighter-expanded"><a name="#codesyntax3"></a><a style="wp-synhighlighter-title" href="#codesyntax3"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="pascal" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>mbr &lt;<span style="color: #339933;">-</span> collection<span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">{
  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><div class="wp-synhighlighter-expanded"><a name="#codesyntax4"></a><a style="wp-synhighlighter-title" href="#codesyntax4"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="pascal" style="font-family:monospace;">collection.<span style="color: #0066ee;">foreach</span><span style="color: #009900;">&#40;</span>mbr <span style="color: #339933;">=</span>&gt; println<span style="color: #009900;">&#40;</span>mbr<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#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><div class="wp-synhighlighter-expanded"><a name="#codesyntax5"></a><a style="wp-synhighlighter-title" href="#codesyntax5"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="pascal" style="font-family:monospace;">val transformed <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>mbr &lt;<span style="color: #339933;">-</span> collection<span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">{
  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><div class="wp-synhighlighter-expanded"><a name="#codesyntax6"></a><a style="wp-synhighlighter-title" href="#codesyntax6"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="pascal" style="font-family:monospace;">val transformed <span style="color: #339933;">=</span> collection.<span style="color: #0066ee;">map</span><span style="color: #009900;">&#40;</span>mbr <span style="color: #339933;">=</span>&gt; transform<span style="color: #009900;">&#40;</span>mbr<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#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><div class="wp-synhighlighter-expanded"><a name="#codesyntax7"></a><a style="wp-synhighlighter-title" href="#codesyntax7"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="pascal" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i &lt;<span style="color: #339933;">-</span> <span style="color: #cc66cc;">0</span> <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #cc66cc;">100000000000</span><span style="color: #009900;">&#41;</span> println<span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#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><div class="wp-synhighlighter-expanded"><a name="#codesyntax8"></a><a style="wp-synhighlighter-title" href="#codesyntax8"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="pascal" style="font-family:monospace;">val numberStrings <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i &lt;<span style="color: #339933;">-</span> <span style="color: #cc66cc;">0</span> <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #cc66cc;">100000000000</span><span style="color: #009900;">&#41;</span> yield <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #339933;">+</span> i<span style="color: #009900;">&#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><div class="wp-synhighlighter-expanded"><a name="#codesyntax9"></a><a style="wp-synhighlighter-title" href="#codesyntax9"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="pascal" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Using the guarded for...yield loop syntactic sugar</span>
val oddSquares <span style="color: #339933;">=</span>
  <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i &lt;<span style="color: #339933;">-</span> <span style="color: #cc66cc;">0</span> <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #cc66cc;">10000000000</span> <span style="color: #000000; font-weight: bold;">if</span> i % <span style="color: #cc66cc;">2</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> yield <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">*</span>i<span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Exactly the same thing as</span>
val oddSquares <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span> <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #cc66cc;">10000000000</span><span style="color: #009900;">&#41;</span>.<span style="color: #0066ee;">filter</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span>&gt;i % <span style="color: #cc66cc;">2</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #0066ee;">map</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span>&gt;i<span style="color: #339933;">*</span>i<span style="color: #009900;">&#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><div class="wp-synhighlighter-expanded"><a name="#codesyntax10"></a><a style="wp-synhighlighter-title" href="#codesyntax10"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="pascal" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Long-winded nested for loop</span>
val pairsThatSumTo100 <span style="color: #339933;">=</span>
  <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i &lt;<span style="color: #339933;">-</span> <span style="color: #cc66cc;">0</span> <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #cc66cc;">100</span>;
      j &lt;<span style="color: #339933;">-</span> i <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #cc66cc;">100</span> <span style="color: #000000; font-weight: bold;">if</span> i <span style="color: #339933;">+</span> j <span style="color: #339933;">==</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span>
    yield Pair<span style="color: #009900;">&#40;</span>i<span style="color: #339933;">,</span> j<span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Slightly shorter but harder to read raw form that gets compiled</span>
val pairsThatSumTo100 <span style="color: #339933;">=</span>
  <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span> <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span>.<span style="color: #0066ee;">flatMap</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span>&gt;<span style="color: #009900;">&#40;</span>i <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span>.<span style="color: #0066ee;">filter</span><span style="color: #009900;">&#40;</span>j<span style="color: #339933;">=</span>&gt;i<span style="color: #339933;">+</span>j<span style="color: #339933;">==</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span>.<span style="color: #0066ee;">map</span><span style="color: #009900;">&#40;</span>j<span style="color: #339933;">=</span>&gt;Pair<span style="color: #009900;">&#40;</span>i<span style="color: #339933;">,</span>j<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#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.</p>
]]></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><div class="wp-synhighlighter-expanded"><a name="#codesyntax11"></a><a style="wp-synhighlighter-title" href="#codesyntax11"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="scala" style="font-family:monospace;"><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">trait</span></a> Iterable<span style="color: #F78811;">&#91;</span>A<span style="color: #F78811;">&#93;</span> <span style="color: #F78811;">&#123;</span>
  ...
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> forall<span style="color: #F78811;">&#40;</span>test<span style="color: #000080;">:</span> <span style="color: #F78811;">&#40;</span>A<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> Boolean<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> Boolean <span style="color: #000080;">=</span> ...
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> find<span style="color: #F78811;">&#40;</span>test<span style="color: #000080;">:</span> <span style="color: #F78811;">&#40;</span>A<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> Boolean<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> Boolean <span style="color: #000080;">=</span> ...
  ...
<span style="color: #F78811;">&#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><div class="wp-synhighlighter-expanded"><a name="#codesyntax12"></a><a style="wp-synhighlighter-title" href="#codesyntax12"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="scala" style="font-family:monospace;"><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">trait</span></a> Iterable<span style="color: #F78811;">&#91;</span>A<span style="color: #F78811;">&#93;</span> <span style="color: #F78811;">&#123;</span>
  ...
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> foldLeft<span style="color: #F78811;">&#91;</span>B<span style="color: #F78811;">&#93;</span> <span style="color: #F78811;">&#40;</span>initialValue<span style="color: #000080;">:</span> B<span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#40;</span>aggregatorFunc<span style="color: #000080;">:</span> <span style="color: #F78811;">&#40;</span>B, A<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> B<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> B <span style="color: #000080;">=</span> ...
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> foldRight<span style="color: #F78811;">&#91;</span>B<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#40;</span>initialValue<span style="color: #000080;">:</span> B<span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#40;</span>aggregatorFunc<span style="color: #000080;">:</span> <span style="color: #F78811;">&#40;</span>B, A<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> B<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> B <span style="color: #000080;">=</span> ...
  ...
<span style="color: #F78811;">&#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><div class="wp-synhighlighter-expanded"><a name="#codesyntax13"></a><a style="wp-synhighlighter-title" href="#codesyntax13"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="scala" style="font-family:monospace;"><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">trait</span></a> Iterable<span style="color: #F78811;">&#91;</span>A<span style="color: #F78811;">&#93;</span> <span style="color: #F78811;">&#123;</span>
  ...
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> foldLeft<span style="color: #F78811;">&#91;</span>B<span style="color: #F78811;">&#93;</span> <span style="color: #F78811;">&#40;</span>initialValue<span style="color: #000080;">:</span> B<span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#40;</span>aggregatorFunc<span style="color: #000080;">:</span> <span style="color: #F78811;">&#40;</span>B, A<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> B<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> B <span style="color: #000080;">=</span> ...
  ...
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> forall<span style="color: #F78811;">&#40;</span>test<span style="color: #000080;">:</span> <span style="color: #F78811;">&#40;</span>A<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> Boolean<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> Boolean <span style="color: #000080;">=</span>
      foldLeft<span style="color: #F78811;">&#40;</span><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">true</span></a><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#40;</span><span style="color: #000080;">_</span> <span style="color: #000080;">&amp;&amp;</span> test<span style="color: #F78811;">&#40;</span><span style="color: #000080;">_</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>
&nbsp;
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> exists<span style="color: #F78811;">&#40;</span>test<span style="color: #000080;">:</span> <span style="color: #F78811;">&#40;</span>A<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> Boolean<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> Boolean <span style="color: #000080;">=</span>
      foldLeft<span style="color: #F78811;">&#40;</span><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">false</span></a><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#40;</span><span style="color: #000080;">_</span> || test<span style="color: #F78811;">&#40;</span><span style="color: #000080;">_</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>
  ...
<span style="color: #F78811;">&#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><div class="wp-synhighlighter-expanded"><a name="#codesyntax14"></a><a style="wp-synhighlighter-title" href="#codesyntax14"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="scala" style="font-family:monospace;"><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">trait</span></a> Iterable<span style="color: #F78811;">&#91;</span>A<span style="color: #F78811;">&#93;</span> <span style="color: #F78811;">&#123;</span>
  ...
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> foldLeft<span style="color: #F78811;">&#91;</span>B<span style="color: #F78811;">&#93;</span> <span style="color: #F78811;">&#40;</span>initialValue<span style="color: #000080;">:</span> B<span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#40;</span>aggregatorFunc<span style="color: #000080;">:</span> <span style="color: #F78811;">&#40;</span>B, A<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> B<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> B <span style="color: #000080;">=</span> ...
  ...
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> mkString<span style="color: #F78811;">&#40;</span>prefix<span style="color: #000080;">:</span> String, separator<span style="color: #000080;">:</span> String, suffix<span style="color: #000080;">:</span> String<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> String <span style="color: #000080;">=</span>
      foldLeft<span style="color: #F78811;">&#40;</span>prefix<span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#40;</span><span style="color: #000080;">_</span> + separator + <span style="color: #000080;">_</span><span style="color: #F78811;">&#41;</span> + suffix
  ...
<span style="color: #F78811;">&#125;</span></pre></div></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.</p>
]]></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>.</p>
]]></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>
		<item>
		<title>Odersky Paper a Must Read to Master Scala</title>
		<link>http://www.blumenfeld-maso.com/2009/12/odersky-paper-a-must-rad-to-master-scala/</link>
		<comments>http://www.blumenfeld-maso.com/2009/12/odersky-paper-a-must-rad-to-master-scala/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 15:51:45 +0000</pubDate>
		<dc:creator>Brian Maso</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blumenfeld-maso.com/?p=39</guid>
		<description><![CDATA[Odersky&#8217;s Scalable Component Abstractions is an absolute must read for anyone planning on mastering Scala. The paper explains the purpose and use of three important Scala idioms you&#8217;d probably take a long time to figure out on your own:

Abstract Type Members. Prior to reading the paper, I figured abstract type members are just another way [...]]]></description>
			<content:encoded><![CDATA[<p>Odersky&#8217;s <a href="http://lamp.epfl.ch/~odersky/papers/ScalableComponent.pdf" target="_blank">Scalable Component Abstractions</a> is an absolute <em>must read</em> for anyone planning on mastering Scala. The paper explains the purpose and use of three important Scala idioms you&#8217;d probably take a long time to figure out on your own:</p>
<ol>
<li><strong>Abstract Type Members</strong>. Prior to reading the paper, I figured abstract type members are just another way of expressing type parameters &#8212; that is, generic type params in Java. Not so! Abstract type members turn out to be an incredibly important  way of promoting code re-use through subtype parameters.</li>
<li><strong>Traits</strong>. &#8220;Module mix-in components&#8221; is the term used in the paper, but in Scala this means <em>traits</em>. The paper explains how traits promote code re-use through much more flexible composition than Java&#8217;s interfaces+single base class.</li>
<li><strong>Explicit Selftypes</strong>. Not so mind expanding as abstract type members and traits, but definitely a concept that needs anchoring for someone coming from Java or similar OO languages.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.blumenfeld-maso.com/2009/12/odersky-paper-a-must-rad-to-master-scala/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scala XML Refs and Tutorials</title>
		<link>http://www.blumenfeld-maso.com/2009/10/scala-xml-refs-and-tutorials/</link>
		<comments>http://www.blumenfeld-maso.com/2009/10/scala-xml-refs-and-tutorials/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 16:30:45 +0000</pubDate>
		<dc:creator>Brian Maso</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.blumenfeld-maso.com/?p=31</guid>
		<description><![CDATA[Some useful links for Scala XML programming and syntax:

scala.xml (free e-reference). From the preface: &#8220;We shed light on Scala&#8217;s XML data model and the syntax of literal XML          markup in Scala code.&#8221;
A Tour of Scala: XML Processing (from Scala Wiki). Useful tutorial of Scala XML processing [...]]]></description>
			<content:encoded><![CDATA[<p>Some useful links for Scala XML programming and syntax:</p>
<ul>
<li><a href="http://burak.emir.googlepages.com/scalaxbook.docbk.html" target="_blank">scala.xml</a> (free e-reference). From the preface: &#8220;We shed light on Scala&#8217;s XML data model and the syntax of literal XML          markup in Scala code.&#8221;</li>
<li><a href="http://www.scala-lang.org/node/131" target="_blank">A Tour of Scala: XML Processing</a> (from Scala Wiki). Useful tutorial of Scala XML processing and progamming, plus description of data-specific XML tool schema2src.</li>
<li><a href="http://www.ibm.com/developerworks/library/x-scalaxml/" target="_blank">IBM devWorks paper on Scala and XML</a>, by <a href="http://fupeg.blogspot.com/" target="_blank">Michael Galpin</a>. Published Apr &#8216;08, so a little old at this point, but still a good intro.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.blumenfeld-maso.com/2009/10/scala-xml-refs-and-tutorials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pipe Operator for Scala</title>
		<link>http://www.blumenfeld-maso.com/2009/10/pipe-operator-for-scala/</link>
		<comments>http://www.blumenfeld-maso.com/2009/10/pipe-operator-for-scala/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 17:33:10 +0000</pubDate>
		<dc:creator>Brian Maso</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://www.blumenfeld-maso.com/?p=5</guid>
		<description><![CDATA[My first not-completely-trivial task in Scala is to implement the equivalent of the F# pipe operator.
Quick Explanation of the Pipe Operator
The pipe operator is syntactic sugar that makes certain patterns of code easier to read. When generating a final result by a sequence of value calculations its easier to read the sequence from left -to-right, [...]]]></description>
			<content:encoded><![CDATA[<p>My first not-completely-trivial task in Scala is to implement the equivalent of the <a href="http://lorgonblog.spaces.live.com/Blog/cns!701679AD17B6D310!165.entry" target="_blank">F# pipe operator</a>.</p>
<h2>Quick Explanation of the Pipe Operator</h2>
<p>The pipe operator is syntactic sugar that makes certain patterns of code easier to read. When generating a final result by a sequence of value calculations its easier to read the sequence from left -to-right, but Scala  only supports passing values to functions in <em>function(value)</em> form, which basically forces the eyes to read the sequence in right-to-left order &#8212; rather unnatural.</p>
<p>Here is one way of expressing a sequence of calculations, relying on local vals to hold intermediate sequence values:</p>
<div><div class="wp-synhighlighter-expanded"><a name="#codesyntax15"></a><a style="wp-synhighlighter-title" href="#codesyntax15"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="scala" style="font-family:monospace;"><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> shuffle<span style="color: #F78811;">&#40;</span>str<span style="color: #000080;">:</span> String<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> String <span style="color: #000080;">=</span> . . .
<a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> randomize<span style="color: #F78811;">&#40;</span>str<span style="color: #000080;">:</span> String<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> String <span style="color: #000080;">=</span> . . .
<a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> camelCase<span style="color: #F78811;">&#40;</span>str<span style="color: #000080;">:</span> String<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> String <span style="color: #000080;">=</span> . . .
<a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> futzWith<span style="color: #F78811;">&#40;</span>str<span style="color: #000080;">:</span> String<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> String <span style="color: #000080;">=</span> . . .
<a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> applySeveralStringTransforms<span style="color: #F78811;">&#40;</span>str<span style="color: #000080;">:</span> String<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> String <span style="color: #000080;">=</span> <span style="color: #F78811;">&#123;</span>
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">val</span></a> shuffled <span style="color: #000080;">=</span> shuffle<span style="color: #F78811;">&#40;</span>str<span style="color: #F78811;">&#41;</span>
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">val</span></a> randomized <span style="color: #000080;">=</span> randomize<span style="color: #F78811;">&#40;</span>shuffled<span style="color: #F78811;">&#41;</span>
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">val</span></a> camelCased <span style="color: #000080;">=</span> camelCase<span style="color: #F78811;">&#40;</span>randomized<span style="color: #F78811;">&#41;</span>
  futzWith<span style="color: #F78811;">&#40;</span>camelCased<span style="color: #F78811;">&#41;</span>
<span style="color: #F78811;">&#125;</span></pre></div></div>
<p>Which reads easy enough &#8212; the result of the function is the result of shuffling, randomizing, camel-casing and finally futzing with the original String. And here&#8217;s the equivalent calculation as a single expression, without local vals. Note how the sequence of calculations is performed from right to left &#8212; first shuffle, then randomize, etc.</p>
<div><div class="wp-synhighlighter-expanded"><a name="#codesyntax16"></a><a style="wp-synhighlighter-title" href="#codesyntax16"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="scala" style="font-family:monospace;"><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> applySeveralStringTransforms<span style="color: #F78811;">&#40;</span>str<span style="color: #000080;">:</span> String<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> String <span style="color: #000080;">=</span> <span style="color: #F78811;">&#123;</span>
  futzWith<span style="color: #F78811;">&#40;</span>camelCase<span style="color: #F78811;">&#40;</span>randomize<span style="color: #F78811;">&#40;</span>shuffle<span style="color: #F78811;">&#40;</span>str<span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>
<span style="color: #F78811;">&#125;</span></pre></div></div>
<p>A pipe operator allows you to pass the result of an expression to the right, preserving left-to-right visual order while still being semantically equivalent to either form above:</p>
<div><div class="wp-synhighlighter-expanded"><a name="#codesyntax17"></a><a style="wp-synhighlighter-title" href="#codesyntax17"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="scala" style="font-family:monospace;"><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> applySeveralStringTransforms<span style="color: #F78811;">&#40;</span>str<span style="color: #000080;">:</span> String<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> String <span style="color: #000080;">=</span> <span style="color: #F78811;">&#123;</span>
  str |<span style="color: #000080;">&gt;</span> shuffle |<span style="color: #000080;">&gt;</span> randomize |<span style="color: #000080;">&gt;</span> camelCase |<span style="color: #000080;">&gt;</span> futzWith
<span style="color: #F78811;">&#125;</span></pre></div></div>
<h2>Attempt # 1: Right-Associative Operator</h2>
<p>My first attempt has me defining a right-associative operator, using <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=179766" target="_blank">Odersky&#8217;s pimp-my-library</a> technique, to generate a temporary PipeFunc object which has a &#8220;|&gt;:&#8221; operator. That is, I&#8217;m using a couple tricks to get the compiler to automatically rewrite this</p>
<div><div class="wp-synhighlighter-expanded"><a name="#codesyntax18"></a><a style="wp-synhighlighter-title" href="#codesyntax18"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="scala" style="font-family:monospace;">x |<span style="color: #000080;">&gt;:</span> func</pre></div></div>
<p>like this</p>
<div><div class="wp-synhighlighter-expanded"><a name="#codesyntax19"></a><a style="wp-synhighlighter-title" href="#codesyntax19"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="scala" style="font-family:monospace;"><span style="color: #F78811;">&#40;</span><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">new</span></a> PipeFunc<span style="color: #F78811;">&#40;</span>func<span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>.|<span style="color: #000080;">&gt;:</span><span style="color: #F78811;">&#40;</span>x<span style="color: #F78811;">&#41;</span></pre></div></div>
<p>Since my operator &#8220;|&gt;:&#8221; ends with a colon, Scala treats it as a &#8220;right-associative&#8221; function &#8212; a function of the right-operand &#8220;func&#8221;, rather than a function of the left-operand &#8220;x&#8221;. A very short-lived PipeFunc object gets created by an implicit conversion, and this object has a method named &#8220;|&gt;:&#8221; that gets applied.</p>
<p>Here&#8217;s the definition of my operator:</p>
<div><div class="wp-synhighlighter-expanded"><a name="#codesyntax20"></a><a style="wp-synhighlighter-title" href="#codesyntax20"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="scala" style="font-family:monospace;"><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">object</span></a> Pipeline <span style="color: #F78811;">&#123;</span>
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">implicit</span></a> <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> toPipeFunc<span style="color: #F78811;">&#91;</span>X, Y<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#40;</span>func<span style="color: #000080;">:</span> X <span style="color: #000080;">=&gt;</span> Y<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=</span> <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">new</span></a> PipeFunc<span style="color: #F78811;">&#40;</span>func<span style="color: #F78811;">&#41;</span>
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">class</span></a> PipeFunc<span style="color: #F78811;">&#91;</span>X, Y<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#40;</span>func<span style="color: #000080;">:</span> X <span style="color: #000080;">=&gt;</span> Y<span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span>
    <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> |<span style="color: #000080;">&gt;:</span><span style="color: #F78811;">&#40;</span>value<span style="color: #000080;">:</span> X<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> Y <span style="color: #000080;">=</span> func<span style="color: #F78811;">&#40;</span>value<span style="color: #F78811;">&#41;</span>
  <span style="color: #F78811;">&#125;</span>
<span style="color: #F78811;">&#125;</span></pre></div></div>
<p>There are immediate problems with this approach. Because of how Scala 2.7.5 (the version I am using) parses this code, it is apparently unable to recognize that the right-hand side of |&gt;: is a function reference. So the following actually causes a compiler error:</p>
<div><div class="wp-synhighlighter-expanded"><a name="#codesyntax21"></a><a style="wp-synhighlighter-title" href="#codesyntax21"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="scala" style="font-family:monospace;"><span style="color: #008000; font-style: italic;">// complains &quot;|&gt;:&quot; is not a function of type Unit</span>
<span style="color: #6666FF;">&quot;Hello, World!&quot;</span> |<span style="color: #000080;">&gt;:</span> println</pre></div></div>
<p>I&#8217;m not sure why this is, but using parens fixes the problem, but makes the expression too surprising and ugly for my taste. I&#8217;m going to have to go back to the drawing board&#8230;</p>
<h2>Attempt #2: Left-Associative Operator</h2>
<p>Instead of augmenting the function argument on the right, I&#8217;ll try augmenting the value argument on the left with a &#8220;|&gt;&#8221; operator. I&#8217;ll use the same pimp-my-library technique to use an implicit conversion of the left-hand object to a temporary object that has a &#8220;|&gt;&#8221; operator, which takes a function as its right-hand argument. That is, I&#8217;m using a couple tricks to get the compiler to automatically convert this</p>
<div><div class="wp-synhighlighter-expanded"><a name="#codesyntax22"></a><a style="wp-synhighlighter-title" href="#codesyntax22"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="scala" style="font-family:monospace;">x |<span style="color: #000080;">&gt;</span> func</pre></div></div>
<p>to this</p>
<div><div class="wp-synhighlighter-expanded"><a name="#codesyntax23"></a><a style="wp-synhighlighter-title" href="#codesyntax23"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="scala" style="font-family:monospace;"><span style="color: #F78811;">&#40;</span><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">new</span></a> PipeLink<span style="color: #F78811;">&#40;</span>x<span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>.|<span style="color: #000080;">&gt;</span><span style="color: #F78811;">&#40;</span>func<span style="color: #F78811;">&#41;</span></pre></div></div>
<p>Here&#8217;s my code for the operator definition:</p>
<div><div class="wp-synhighlighter-expanded"><a name="#codesyntax24"></a><a style="wp-synhighlighter-title" href="#codesyntax24"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="scala" style="font-family:monospace;"><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">object</span></a> Pipeline <span style="color: #F78811;">&#123;</span>
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">implicit</span></a> <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> toPipeLink<span style="color: #F78811;">&#91;</span>X<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#40;</span>v<span style="color: #000080;">:</span> X<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> PipeLink<span style="color: #F78811;">&#91;</span>X<span style="color: #F78811;">&#93;</span> <span style="color: #000080;">=</span> <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">new</span></a> PipeLink<span style="color: #F78811;">&#91;</span>X<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#40;</span>v<span style="color: #F78811;">&#41;</span>
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">class</span></a> PipeLink<span style="color: #F78811;">&#91;</span>X<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#40;</span>value<span style="color: #000080;">:</span> X<span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span>
    <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> |<span style="color: #000080;">&gt;</span><span style="color: #F78811;">&#91;</span>Y<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#40;</span>func<span style="color: #000080;">:</span> X <span style="color: #000080;">=&gt;</span> Y<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> Y <span style="color: #000080;">=</span> func<span style="color: #F78811;">&#40;</span>value<span style="color: #F78811;">&#41;</span>
  <span style="color: #F78811;">&#125;</span>
<span style="color: #F78811;">&#125;</span></pre></div></div>
<p>OK, works correctly, and doesn&#8217;t have any of the problems that the right-associative operator had.</p>
<p>I do have a hidden performance issue: creation of an very-short-lived temporary object. Consider how the the following single expression gets rewritten by the Scala compiler:</p>
<div><div class="wp-synhighlighter-expanded"><a name="#codesyntax25"></a><a style="wp-synhighlighter-title" href="#codesyntax25"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="scala" style="font-family:monospace;">str |<span style="color: #000080;">&gt;</span> shuffle |<span style="color: #000080;">&gt;</span> randomize |<span style="color: #000080;">&gt;</span> camelCase |<span style="color: #000080;">&gt;</span> futzWith</pre></div></div>
<p>to this:</p>
<div><div class="wp-synhighlighter-expanded"><a name="#codesyntax26"></a><a style="wp-synhighlighter-title" href="#codesyntax26"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="scala" style="font-family:monospace;"><span style="color: #F78811;">&#40;</span><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">new</span></a> PipeLink<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#40;</span><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">new</span></a> PipeLink<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#40;</span><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">new</span></a> PipeLink<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#40;</span><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">new</span></a> PipeLink<span style="color: #F78811;">&#40;</span>str<span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>.
    |<span style="color: #000080;">&gt;</span><span style="color: #F78811;">&#40;</span>shuffle<span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>.|<span style="color: #000080;">&gt;</span><span style="color: #F78811;">&#40;</span>randomize<span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>.|<span style="color: #000080;">&gt;</span><span style="color: #F78811;">&#40;</span>camelCase<span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>.|<span style="color: #000080;">&gt;</span><span style="color: #F78811;">&#40;</span>futzWith<span style="color: #F78811;">&#41;</span></pre></div></div>
<p>Ugly &#8211; obviously; wastefully creates too many objects &#8211; also true. 4 temporary PipeLinks created and thrown away. The JVM GC is pretty good at handling short-lived objects, but this is terribly wasteful. I can&#8217;t think of a way of getting rid of temporary objects &#8212; any suggestions greatly appreciated!</p>
<h2>Smarter Than Me</h2>
<p>Only after implementing did I find that <a href="http://www.blogger.com/profile/03622573187942388226" target="_blank">Steve Gilham</a> had already posted his <a href="http://stevegilham.blogspot.com/2009/01/pipe-operator-in-scala.html" target="_blank">implementation of the pipe operator</a>. He immediately went with a left-associative operator implementation. Must be a clever guy! Both his solution and mine suffer from creating a temp object with each invocation of the pipe operator.</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 1618px; width: 1px; height: 1px;">// complains &#8220;|&gt;:&#8221; is not a function of type Unit</div>
]]></content:encoded>
			<wfw:commentRss>http://www.blumenfeld-maso.com/2009/10/pipe-operator-for-scala/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
