<?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>Robert Horvick</title>
	<atom:link href="http://www.roberthorvick.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.roberthorvick.com</link>
	<description>Things my wife doesn&#039;t want on the family blog...</description>
	<lastBuildDate>Thu, 20 Aug 2009 00:31:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>User Experience Tip: Don&#8217;t mix units</title>
		<link>http://www.roberthorvick.com/2009/08/19/user-experience-tip-dont-mix-units/</link>
		<comments>http://www.roberthorvick.com/2009/08/19/user-experience-tip-dont-mix-units/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 00:31:31 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.roberthorvick.com/2009/08/19/user-experience-tip-dont-mix-units/</guid>
		<description><![CDATA[I need how much space?
 
Maybe I’m dense.&#160; But I had to read this window not once or twice … but 5, yes 5, times before I realized that it was giving the “Required” units in “KB” and “Available” units in “MB”.
Please … unless your UX is a “convert unit X to Y” window, stick [...]]]></description>
			<content:encoded><![CDATA[<p>I need how much space?</p>
<p><a href="http://www.roberthorvick.com/images/UserExperienceTipDontmixunits_1136A/image.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.roberthorvick.com/images/UserExperienceTipDontmixunits_1136A/image_thumb.png" width="517" height="402" /></a> </p>
<p>Maybe I’m dense.&#160; But I had to read this window not once or twice … but 5, yes 5, times before I realized that it was giving the “Required” units in “KB” and “Available” units in “MB”.</p>
<p>Please … unless your UX is a “convert unit X to Y” window, stick to one unit.</p>



Share and Enjoy:


	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F19%252Fuser-experience-tip-dont-mix-units%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="twitter" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DUser%2520Experience%2520Tip%253A%2520Don%2526rsquo%253Bt%2520mix%2520units%2520-%2520http%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F19%252Fuser-experience-tip-dont-mix-units%252F';" title="Twitter"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F19%252Fuser-experience-tip-dont-mix-units%252F%26amp%3Btitle%3DUser%2520Experience%2520Tip%253A%2520Don%2526rsquo%253Bt%2520mix%2520units%26amp%3Bbodytext%3DI%2520need%2520how%2520much%2520space%253F%2520%2520%2520%2520%2520Maybe%2520I%25E2%2580%2599m%2520dense.%2526%2523160%253B%2520But%2520I%2520had%2520to%2520read%2520this%2520window%2520not%2520once%2520or%2520twice%2520%25E2%2580%25A6%2520but%25205%252C%2520yes%25205%252C%2520times%2520before%2520I%2520realized%2520that%2520it%2520was%2520giving%2520the%2520%25E2%2580%259CRequired%25E2%2580%259D%2520units%2520in%2520%25E2%2580%259CKB%25E2%2580%259D%2520and%2520%25E2%2580%259CAvailable%25E2%2580%259D%2520units%2520in%2520%25E2%2580%259CMB%25E2%2580%259D.%2520%2520Please%2520%25E2%2580%25A6%2520u';" title="Digg"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="reddit" href="javascript:window.location='http%3A%2F%2Freddit.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F19%252Fuser-experience-tip-dont-mix-units%252F%26amp%3Btitle%3DUser%2520Experience%2520Tip%253A%2520Don%2526rsquo%253Bt%2520mix%2520units';" title="Reddit"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F19%252Fuser-experience-tip-dont-mix-units%252F%26amp%3Btitle%3DUser%2520Experience%2520Tip%253A%2520Don%2526rsquo%253Bt%2520mix%2520units%26amp%3Bnotes%3DI%2520need%2520how%2520much%2520space%253F%2520%2520%2520%2520%2520Maybe%2520I%25E2%2580%2599m%2520dense.%2526%2523160%253B%2520But%2520I%2520had%2520to%2520read%2520this%2520window%2520not%2520once%2520or%2520twice%2520%25E2%2580%25A6%2520but%25205%252C%2520yes%25205%252C%2520times%2520before%2520I%2520realized%2520that%2520it%2520was%2520giving%2520the%2520%25E2%2580%259CRequired%25E2%2580%259D%2520units%2520in%2520%25E2%2580%259CKB%25E2%2580%259D%2520and%2520%25E2%2580%259CAvailable%25E2%2580%259D%2520units%2520in%2520%25E2%2580%259CMB%25E2%2580%259D.%2520%2520Please%2520%25E2%2580%25A6%2520u';" title="del.icio.us"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F19%252Fuser-experience-tip-dont-mix-units%252F%26amp%3Bt%3DUser%2520Experience%2520Tip%253A%2520Don%2526rsquo%253Bt%2520mix%2520units';" title="Facebook"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F19%252Fuser-experience-tip-dont-mix-units%252F%26amp%3Btitle%3DUser%2520Experience%2520Tip%253A%2520Don%2526rsquo%253Bt%2520mix%2520units%26amp%3Bannotation%3DI%2520need%2520how%2520much%2520space%253F%2520%2520%2520%2520%2520Maybe%2520I%25E2%2580%2599m%2520dense.%2526%2523160%253B%2520But%2520I%2520had%2520to%2520read%2520this%2520window%2520not%2520once%2520or%2520twice%2520%25E2%2580%25A6%2520but%25205%252C%2520yes%25205%252C%2520times%2520before%2520I%2520realized%2520that%2520it%2520was%2520giving%2520the%2520%25E2%2580%259CRequired%25E2%2580%259D%2520units%2520in%2520%25E2%2580%259CKB%25E2%2580%259D%2520and%2520%25E2%2580%259CAvailable%25E2%2580%259D%2520units%2520in%2520%25E2%2580%259CMB%25E2%2580%259D.%2520%2520Please%2520%25E2%2580%25A6%2520u';" title="Google Bookmarks"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="stumbleupon" href="javascript:window.location='http%3A%2F%2Fwww.stumbleupon.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F19%252Fuser-experience-tip-dont-mix-units%252F%26amp%3Btitle%3DUser%2520Experience%2520Tip%253A%2520Don%2526rsquo%253Bt%2520mix%2520units';" title="StumbleUpon"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.roberthorvick.com/2009/08/19/user-experience-tip-dont-mix-units/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Snap! Crackle! Pop!  &#8211; Clicks and Pops in Cakewalk Sonar 8</title>
		<link>http://www.roberthorvick.com/2009/08/15/snap-crackle-pop-clicks-and-pops-in-cakewalk-sonar-8/</link>
		<comments>http://www.roberthorvick.com/2009/08/15/snap-crackle-pop-clicks-and-pops-in-cakewalk-sonar-8/#comments</comments>
		<pubDate>Sat, 15 Aug 2009 04:05:30 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[Home Studio]]></category>
		<category><![CDATA[alesis]]></category>
		<category><![CDATA[homestudio]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[photon]]></category>
		<category><![CDATA[sonar]]></category>

		<guid isPermaLink="false">http://www.roberthorvick.com/2009/08/15/snap-crackle-pop-clicks-and-pops-in-cakewalk-sonar-8/</guid>
		<description><![CDATA[I’m may not be the brightest bulb in the pack but I do know a couple-a-things about a buncha-stuff.&#160; One of those things is that when I plug a keyboard into my computer and open Cakewalk Sonar (8 Producer Trial) I expect to hear sounds.&#160; The other is that when I finally hear those sounds [...]]]></description>
			<content:encoded><![CDATA[<p>I’m may not be the brightest bulb in the pack but I do know a couple-a-things about a buncha-stuff.&#160; One of those things is that when I plug a keyboard into my computer and open Cakewalk Sonar (8 Producer Trial) I expect to hear sounds.&#160; The other is that when I finally hear those sounds they shouldn’t be punctuated with a loud (louder than the audio being played) click ever half second or so.</p>
<p>Not even exaggerating – it was like a slightly off-beat metronome was overpowering what I was playing.</p>
<p><strong>Getting the Sound…</strong></p>
<p>I plugged my Alesis Photon x25 into my Windows 7 laptop and then started Sonar 8.&#160; I’m immediately greeted with the message that either the Photon is not supported or in use.&#160; I’m going to assume it’s in use by Windows and just move on … click “Use Anyway”</p>
<p>Create a new project … delete all the audio tracks … add a MIDI track … hit a key.&#160; Whoa!&#160; Hmmm … no sound.&#160; Oh!&#160; Forgot to add a synth (I came across this when doing “Tutorial 1” in the Sonar help file … yeah … I read it.&#160; I read the Readme too).&#160; So I add a synth.&#160; Now I hit a key and … still nothing.&#160; The signal indicator is peaking so I know I’m getting the input from the keyboard to the DAW.&#160; Time to try some random things and then hit the tubes looking for an answer.</p>
<p>Let me save you the trouble:</p>
<p><a href="http://www.cakewalk.com/Support/FAQ/MIDI2Audio.aspx">http://www.cakewalk.com/Support/FAQ/MIDI2Audio.aspx</a></p>
<p>Read the whole thing.&#160; It was section three I cared about.&#160; Specifically to check “All Synth Audio Outputs: Stereo” and to map the outputs to the synth.</p>
<p>But still no sound – oh crap – it’s playing through the Photon and not my sound card!&#160; Awesome!&#160; I plugged in a set of head phones and I’m off.&#160; This is great.</p>
<p><strong>But it sounds horrible …</strong></p>
<p>clicks and pops like mad.</p>
<p>Again … let me save you the trouble:</p>
<p><a href="http://www.cakewalk.com/support/FAQ/SR_FAQ.aspx#9">http://www.cakewalk.com/support/FAQ/SR_FAQ.aspx#9</a></p>
<p>Adjusting my buffer to “Safe” made it better so I knew I was on the right track – but changing my driver from WDM to MME was the key (ASIO didn’t work – no sound … I’ll look into that some other time).&#160; Once I was switch to MME I was able to drop my latency back to 10ms.&#160; At 10ms I get an occasional pop.&#160; At 30ms almost none.&#160; At 90 – I’ve yet to hear any.&#160; Beauty!</p>
<p>Now to find some free VST synths because the ones in the Trial are … just horrible.&#160; It’s like they are punishing you for using the trial.&#160; Give me a drum kit or piano please!&#160; Some congas and a shaker … anything.&#160; Jeez.</p>
<p>(they are probably there and I just don’t know how to use them yet … but the forums I read all said things like “the trial has crap sounds … get free VSTs”).</p>



Share and Enjoy:


	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F15%252Fsnap-crackle-pop-clicks-and-pops-in-cakewalk-sonar-8%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="twitter" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DSnap%2521%2520Crackle%2521%2520Pop%2521%2520%2520-%2520Clicks%2520and%2520Pops%2520in%2520Cakewalk%2520Sonar%25208%2520-%2520http%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F15%252Fsnap-crackle-pop-clicks-and-pops-in-cakewalk-sonar-8%252F';" title="Twitter"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F15%252Fsnap-crackle-pop-clicks-and-pops-in-cakewalk-sonar-8%252F%26amp%3Btitle%3DSnap%2521%2520Crackle%2521%2520Pop%2521%2520%2520-%2520Clicks%2520and%2520Pops%2520in%2520Cakewalk%2520Sonar%25208%26amp%3Bbodytext%3DI%25E2%2580%2599m%2520may%2520not%2520be%2520the%2520brightest%2520bulb%2520in%2520the%2520pack%2520but%2520I%2520do%2520know%2520a%2520couple-a-things%2520about%2520a%2520buncha-stuff.%2526%2523160%253B%2520One%2520of%2520those%2520things%2520is%2520that%2520when%2520I%2520plug%2520a%2520keyboard%2520into%2520my%2520computer%2520and%2520open%2520Cakewalk%2520Sonar%2520%25288%2520Producer%2520Trial%2529%2520I%2520expect%2520to%2520hear%2520sounds.%2526%2523160%253B%2520';" title="Digg"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="reddit" href="javascript:window.location='http%3A%2F%2Freddit.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F15%252Fsnap-crackle-pop-clicks-and-pops-in-cakewalk-sonar-8%252F%26amp%3Btitle%3DSnap%2521%2520Crackle%2521%2520Pop%2521%2520%2520-%2520Clicks%2520and%2520Pops%2520in%2520Cakewalk%2520Sonar%25208';" title="Reddit"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F15%252Fsnap-crackle-pop-clicks-and-pops-in-cakewalk-sonar-8%252F%26amp%3Btitle%3DSnap%2521%2520Crackle%2521%2520Pop%2521%2520%2520-%2520Clicks%2520and%2520Pops%2520in%2520Cakewalk%2520Sonar%25208%26amp%3Bnotes%3DI%25E2%2580%2599m%2520may%2520not%2520be%2520the%2520brightest%2520bulb%2520in%2520the%2520pack%2520but%2520I%2520do%2520know%2520a%2520couple-a-things%2520about%2520a%2520buncha-stuff.%2526%2523160%253B%2520One%2520of%2520those%2520things%2520is%2520that%2520when%2520I%2520plug%2520a%2520keyboard%2520into%2520my%2520computer%2520and%2520open%2520Cakewalk%2520Sonar%2520%25288%2520Producer%2520Trial%2529%2520I%2520expect%2520to%2520hear%2520sounds.%2526%2523160%253B%2520';" title="del.icio.us"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F15%252Fsnap-crackle-pop-clicks-and-pops-in-cakewalk-sonar-8%252F%26amp%3Bt%3DSnap%2521%2520Crackle%2521%2520Pop%2521%2520%2520-%2520Clicks%2520and%2520Pops%2520in%2520Cakewalk%2520Sonar%25208';" title="Facebook"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F15%252Fsnap-crackle-pop-clicks-and-pops-in-cakewalk-sonar-8%252F%26amp%3Btitle%3DSnap%2521%2520Crackle%2521%2520Pop%2521%2520%2520-%2520Clicks%2520and%2520Pops%2520in%2520Cakewalk%2520Sonar%25208%26amp%3Bannotation%3DI%25E2%2580%2599m%2520may%2520not%2520be%2520the%2520brightest%2520bulb%2520in%2520the%2520pack%2520but%2520I%2520do%2520know%2520a%2520couple-a-things%2520about%2520a%2520buncha-stuff.%2526%2523160%253B%2520One%2520of%2520those%2520things%2520is%2520that%2520when%2520I%2520plug%2520a%2520keyboard%2520into%2520my%2520computer%2520and%2520open%2520Cakewalk%2520Sonar%2520%25288%2520Producer%2520Trial%2529%2520I%2520expect%2520to%2520hear%2520sounds.%2526%2523160%253B%2520';" title="Google Bookmarks"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="stumbleupon" href="javascript:window.location='http%3A%2F%2Fwww.stumbleupon.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F15%252Fsnap-crackle-pop-clicks-and-pops-in-cakewalk-sonar-8%252F%26amp%3Btitle%3DSnap%2521%2520Crackle%2521%2520Pop%2521%2520%2520-%2520Clicks%2520and%2520Pops%2520in%2520Cakewalk%2520Sonar%25208';" title="StumbleUpon"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.roberthorvick.com/2009/08/15/snap-crackle-pop-clicks-and-pops-in-cakewalk-sonar-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Alesis Photon x25 on Windows 7</title>
		<link>http://www.roberthorvick.com/2009/08/14/alesis-photon-x25-on-windows-7/</link>
		<comments>http://www.roberthorvick.com/2009/08/14/alesis-photon-x25-on-windows-7/#comments</comments>
		<pubDate>Sat, 15 Aug 2009 02:08:24 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[Home Studio]]></category>
		<category><![CDATA[alesis]]></category>
		<category><![CDATA[homestudio]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[photon]]></category>

		<guid isPermaLink="false">http://www.roberthorvick.com/2009/08/14/alesis-photon-x25-on-windows-7/</guid>
		<description><![CDATA[I’ve made a pretty firm commitment to not get too deep into buying gear before I’ve really figured out what it is that I want – but I had a chance to pick up an Alesis Photon x25 MIDI controller with Cubase LE for about $40 today.&#160; The controller was purchased new about 2 months [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve made a pretty firm commitment to not get too deep into buying gear before I’ve really figured out what it is that I want – but I had a chance to pick up an Alesis Photon x25 MIDI controller with Cubase LE for about $40 today.&#160; The controller was purchased new about 2 months ago, returned in favor of another model and has sat in the “Used Equipment” window since then.&#160; I’ve watch the price fall and fall and today sniped it for a fifth of it’s street price a few months ago.</p>
<p>But why?</p>
<p>Creating a home studio is as much about software as hardware – and testing what DAW I like requires two things:</p>
<ol>
<li>A DAW</li>
<li>An input device to do something useful in said DAW</li>
</ol>
<p>This unit comes with Cubase LE and Sonar 8 Producer is available for a 30 day trial … so there I go.&#160; I have the software and a crazy cheap way to test it out.&#160; And when I&#8217;ve made up my mind I’ve also got a nice little MIDI controller.</p>
<p>That’s how I rationalized it to myself.&#160; Did it work for you too?</p>
<p>My contented feeling was short lived though.&#160; After picking it up I went out to dinner with a few of my kids and got to spend a few hours fretting over whether or not this device would be compatible with Windows 7.&#160; The M-Audio KeyRig <a href="http://twitter.com/noahcoad/status/3303462990">isn’t</a> (<a href="http://twitter.com/noahcoad/status/3310307595">more</a>) – would this device be?&#160; It’s not the newest unit on the block – discontinued in fact.</p>
<p>But I plugged it in and …</p>
<p><a href="http://www.roberthorvick.com/images/AlesisPhotonx25onWindows7_13311/image.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.roberthorvick.com/images/AlesisPhotonx25onWindows7_13311/image_thumb.png" width="540" height="201" /></a> </p>
<p>Now … I haven’t done anything beyond this.&#160; So does it work?&#160; I’m installing Cubase LE now … </p>
<p>Hmmm.</p>
<p>Well.&#160; Plan has hit a kink.&#160; The previous owner claimed he never registered Cubase but apparently he took the registration code.&#160; So I have 30 days to decide if I want to keep this or not.&#160; Let’s see how Sonar likes it… (next time).</p>



Share and Enjoy:


	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F14%252Falesis-photon-x25-on-windows-7%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="twitter" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DAlesis%2520Photon%2520x25%2520on%2520Windows%25207%2520-%2520http%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F14%252Falesis-photon-x25-on-windows-7%252F';" title="Twitter"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F14%252Falesis-photon-x25-on-windows-7%252F%26amp%3Btitle%3DAlesis%2520Photon%2520x25%2520on%2520Windows%25207%26amp%3Bbodytext%3DI%25E2%2580%2599ve%2520made%2520a%2520pretty%2520firm%2520commitment%2520to%2520not%2520get%2520too%2520deep%2520into%2520buying%2520gear%2520before%2520I%25E2%2580%2599ve%2520really%2520figured%2520out%2520what%2520it%2520is%2520that%2520I%2520want%2520%25E2%2580%2593%2520but%2520I%2520had%2520a%2520chance%2520to%2520pick%2520up%2520an%2520Alesis%2520Photon%2520x25%2520MIDI%2520controller%2520with%2520Cubase%2520LE%2520for%2520about%2520%252440%2520today.%2526%2523160%253B%2520The%2520con';" title="Digg"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="reddit" href="javascript:window.location='http%3A%2F%2Freddit.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F14%252Falesis-photon-x25-on-windows-7%252F%26amp%3Btitle%3DAlesis%2520Photon%2520x25%2520on%2520Windows%25207';" title="Reddit"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F14%252Falesis-photon-x25-on-windows-7%252F%26amp%3Btitle%3DAlesis%2520Photon%2520x25%2520on%2520Windows%25207%26amp%3Bnotes%3DI%25E2%2580%2599ve%2520made%2520a%2520pretty%2520firm%2520commitment%2520to%2520not%2520get%2520too%2520deep%2520into%2520buying%2520gear%2520before%2520I%25E2%2580%2599ve%2520really%2520figured%2520out%2520what%2520it%2520is%2520that%2520I%2520want%2520%25E2%2580%2593%2520but%2520I%2520had%2520a%2520chance%2520to%2520pick%2520up%2520an%2520Alesis%2520Photon%2520x25%2520MIDI%2520controller%2520with%2520Cubase%2520LE%2520for%2520about%2520%252440%2520today.%2526%2523160%253B%2520The%2520con';" title="del.icio.us"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F14%252Falesis-photon-x25-on-windows-7%252F%26amp%3Bt%3DAlesis%2520Photon%2520x25%2520on%2520Windows%25207';" title="Facebook"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F14%252Falesis-photon-x25-on-windows-7%252F%26amp%3Btitle%3DAlesis%2520Photon%2520x25%2520on%2520Windows%25207%26amp%3Bannotation%3DI%25E2%2580%2599ve%2520made%2520a%2520pretty%2520firm%2520commitment%2520to%2520not%2520get%2520too%2520deep%2520into%2520buying%2520gear%2520before%2520I%25E2%2580%2599ve%2520really%2520figured%2520out%2520what%2520it%2520is%2520that%2520I%2520want%2520%25E2%2580%2593%2520but%2520I%2520had%2520a%2520chance%2520to%2520pick%2520up%2520an%2520Alesis%2520Photon%2520x25%2520MIDI%2520controller%2520with%2520Cubase%2520LE%2520for%2520about%2520%252440%2520today.%2526%2523160%253B%2520The%2520con';" title="Google Bookmarks"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="stumbleupon" href="javascript:window.location='http%3A%2F%2Fwww.stumbleupon.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F14%252Falesis-photon-x25-on-windows-7%252F%26amp%3Btitle%3DAlesis%2520Photon%2520x25%2520on%2520Windows%25207';" title="StumbleUpon"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.roberthorvick.com/2009/08/14/alesis-photon-x25-on-windows-7/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Budget Home Studio: what type of audio input device?</title>
		<link>http://www.roberthorvick.com/2009/08/14/budget-home-studio-what-type-of-audio-input-device/</link>
		<comments>http://www.roberthorvick.com/2009/08/14/budget-home-studio-what-type-of-audio-input-device/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 05:37:15 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[Home Studio]]></category>
		<category><![CDATA[homestudio]]></category>
		<category><![CDATA[music]]></category>

		<guid isPermaLink="false">http://www.roberthorvick.com/2009/08/14/budget-home-studio-what-type-of-audio-input-device/</guid>
		<description><![CDATA[I learned something about myself this week.  I can’t stand it when people refer to an externally connected (FireWire or USB) audio device a “sound card”.

One of these things is not like the other.  Know which one?  The one that’s actually a card.  The other are boxes.
I’m going to start referring to printers as “printer [...]]]></description>
			<content:encoded><![CDATA[<p>I learned something about myself this week.  I can’t stand it when people refer to an externally connected (FireWire or USB) audio device a “sound card”.</p>
<p><a href="http://www.roberthorvick.com/images/BudgetHomeStudiowhattypeofaudioinputdevi_14F/audiocards.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="audio-cards" src="http://www.roberthorvick.com/images/BudgetHomeStudiowhattypeofaudioinputdevi_14F/audiocards_thumb.png" border="0" alt="audio-cards" width="454" height="360" /></a></p>
<p>One of these things is not like the other.  Know which one?  The one that’s actually a card.  The other are boxes.</p>
<p>I’m going to start referring to printers as “printer card”.  That’ll show’em.</p>
<p><strong>Moving on…</strong></p>
<p>Let me get you up to speed.  I have more time than money ($1000) and I want to put together an inexpensive home recording studio.</p>
<p>The first decision I made after several days of researching: I’m not using a digital-recorder-mixer combination plate.  At first I thought I was.  I had even figured out which one – the <a href="http://www.samsontech.com/products/productpage.cfm?prodID=1918">Zoom HD8CD</a>.</p>
<p><a href="http://www.roberthorvick.com/images/BudgetHomeStudiowhattypeofaudioinputdevi_14F/zoomhd8cd.png"><img style="border-right-width: 0px; margin: 0px 10px 5px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="zoom-hd8cd" src="http://www.roberthorvick.com/images/BudgetHomeStudiowhattypeofaudioinputdevi_14F/zoomhd8cd_thumb.png" border="0" alt="zoom-hd8cd" width="311" height="183" align="left" /></a></p>
<p>This seemed ideal on the surface.  Buy one thing and just be done with it – even a CD burner.  It can communicate with a DAW to do further processing and mixing on the computer.  What’s not to like?</p>
<p>Well … it comes down to several factors.  Things like only being able to record 2 tracks at once … and those tracks are 44/1Khz 24 bit (mixed down to 16 bit mono).  Very limited EQ means I’ll spend a lot of time in the DAW anyway.  Questionable preamps (the only question is “how bad are they?”).  I don’t need a CD writer but I’m still paying for it (instead of paying for something I do need).</p>
<p>So at the end of the day I get a highly convenient device (a card?) of that leaves me disappointed on pretty much every front but which does get the job done.  Sure – I could spend more and get a better device but the price jump between “crappy” and “nice” is well outside of my budget.</p>
<p>So what are my options?  Well – there is a PCI card or an external device connected by USB or FireWire.</p>
<p><a href="http://www.roberthorvick.com/images/BudgetHomeStudiowhattypeofaudioinputdevi_14F/pciaudiocard.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="pci-audio-card" src="http://www.roberthorvick.com/images/BudgetHomeStudiowhattypeofaudioinputdevi_14F/pciaudiocard_thumb.png" border="0" alt="pci-audio-card" width="229" height="229" align="right" /></a></p>
<p>I’m using a laptop so PCI is out (and even if it were an option I wouldn’t necessary want it).  And since I’m using a lower-end laptop I don’t want to use USB since it puts more pressure on the CPU and has lower real-world transfer rates compared to FireWire.  I want to get everything I can out of what I have.</p>
<p>There.  I just saved you three days of reading and thinking.</p>
<p><strong>You want an external device audio input device connected to your computer via FireWire.</strong></p>
<p>That’s what I want and that’s what you want.</p>
<p>Next time I’ll look at some of the options I’m considering.</p>



Share and Enjoy:


	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F14%252Fbudget-home-studio-what-type-of-audio-input-device%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="twitter" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DBudget%2520Home%2520Studio%253A%2520what%2520type%2520of%2520audio%2520input%2520device%253F%2520-%2520http%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F14%252Fbudget-home-studio-what-type-of-audio-input-device%252F';" title="Twitter"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F14%252Fbudget-home-studio-what-type-of-audio-input-device%252F%26amp%3Btitle%3DBudget%2520Home%2520Studio%253A%2520what%2520type%2520of%2520audio%2520input%2520device%253F%26amp%3Bbodytext%3DI%2520learned%2520something%2520about%2520myself%2520this%2520week.%25C2%25A0%2520I%2520can%25E2%2580%2599t%2520stand%2520it%2520when%2520people%2520refer%2520to%2520an%2520externally%2520connected%2520%2528FireWire%2520or%2520USB%2529%2520audio%2520device%2520a%2520%25E2%2580%259Csound%2520card%25E2%2580%259D.%250D%250A%250D%250A%250D%250A%250D%250AOne%2520of%2520these%2520things%2520is%2520not%2520like%2520the%2520other.%25C2%25A0%2520Know%2520which%2520one%253F%25C2%25A0%2520The%2520one%2520that%25E2%2580%2599s%2520ac';" title="Digg"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="reddit" href="javascript:window.location='http%3A%2F%2Freddit.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F14%252Fbudget-home-studio-what-type-of-audio-input-device%252F%26amp%3Btitle%3DBudget%2520Home%2520Studio%253A%2520what%2520type%2520of%2520audio%2520input%2520device%253F';" title="Reddit"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F14%252Fbudget-home-studio-what-type-of-audio-input-device%252F%26amp%3Btitle%3DBudget%2520Home%2520Studio%253A%2520what%2520type%2520of%2520audio%2520input%2520device%253F%26amp%3Bnotes%3DI%2520learned%2520something%2520about%2520myself%2520this%2520week.%25C2%25A0%2520I%2520can%25E2%2580%2599t%2520stand%2520it%2520when%2520people%2520refer%2520to%2520an%2520externally%2520connected%2520%2528FireWire%2520or%2520USB%2529%2520audio%2520device%2520a%2520%25E2%2580%259Csound%2520card%25E2%2580%259D.%250D%250A%250D%250A%250D%250A%250D%250AOne%2520of%2520these%2520things%2520is%2520not%2520like%2520the%2520other.%25C2%25A0%2520Know%2520which%2520one%253F%25C2%25A0%2520The%2520one%2520that%25E2%2580%2599s%2520ac';" title="del.icio.us"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F14%252Fbudget-home-studio-what-type-of-audio-input-device%252F%26amp%3Bt%3DBudget%2520Home%2520Studio%253A%2520what%2520type%2520of%2520audio%2520input%2520device%253F';" title="Facebook"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F14%252Fbudget-home-studio-what-type-of-audio-input-device%252F%26amp%3Btitle%3DBudget%2520Home%2520Studio%253A%2520what%2520type%2520of%2520audio%2520input%2520device%253F%26amp%3Bannotation%3DI%2520learned%2520something%2520about%2520myself%2520this%2520week.%25C2%25A0%2520I%2520can%25E2%2580%2599t%2520stand%2520it%2520when%2520people%2520refer%2520to%2520an%2520externally%2520connected%2520%2528FireWire%2520or%2520USB%2529%2520audio%2520device%2520a%2520%25E2%2580%259Csound%2520card%25E2%2580%259D.%250D%250A%250D%250A%250D%250A%250D%250AOne%2520of%2520these%2520things%2520is%2520not%2520like%2520the%2520other.%25C2%25A0%2520Know%2520which%2520one%253F%25C2%25A0%2520The%2520one%2520that%25E2%2580%2599s%2520ac';" title="Google Bookmarks"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="stumbleupon" href="javascript:window.location='http%3A%2F%2Fwww.stumbleupon.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F14%252Fbudget-home-studio-what-type-of-audio-input-device%252F%26amp%3Btitle%3DBudget%2520Home%2520Studio%253A%2520what%2520type%2520of%2520audio%2520input%2520device%253F';" title="StumbleUpon"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.roberthorvick.com/2009/08/14/budget-home-studio-what-type-of-audio-input-device/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Budget Home Recording Studio</title>
		<link>http://www.roberthorvick.com/2009/08/13/creating-a-budget-home-recording-studio/</link>
		<comments>http://www.roberthorvick.com/2009/08/13/creating-a-budget-home-recording-studio/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 03:16:50 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[Home Studio]]></category>
		<category><![CDATA[homestudio]]></category>
		<category><![CDATA[music]]></category>

		<guid isPermaLink="false">http://www.roberthorvick.com/2009/08/13/creating-a-budget-home-recording-studio/</guid>
		<description><![CDATA[I’m in the planning stages of putting together a home recording studio for capturing the musical ideas that no one else wants to hear.&#160; In high school I spent my junior year at the Minnesota Center for Arts Education (I spent my senior year preparing to have my first child but that’s another story for [...]]]></description>
			<content:encoded><![CDATA[<p>I’m in the planning stages of putting together a home recording studio for capturing the musical ideas that no one else wants to hear.&#160; In high school I spent my junior year at the <a href="http://www.pcae.k12.mn.us/">Minnesota Center for Arts Education</a> (I spent my senior year preparing to have my first child but that’s another story for another time) – while at MCAE I had the opportunity to spend my afternoons (and many many nights) in a very nice production studio.&#160; Many many thousands of dollars of gear – much of which you couldn’t give away today.&#160; The point being that I’m familiar with what a high-end home studio would have looked like 15 years ago – unfortunately that knowledge does not do me a whole lot of good.</p>
<p><strong>What I have</strong></p>
<ol>
<li>A 6’x10’ space to work with. </li>
<li>A laptop computer (Acer Extensa 5620Z – jealous much?) </li>
<li>$1000 (my wife may disagree with this assertion but she is out of town) </li>
</ol>
<p><strong>What I want</strong></p>
<ol>
<li>To be able to capture my guitars (electric and acoustic) and vocals </li>
<li>A MIDI input keyboard </li>
<li>Gear that is not crap and can grow into better things </li>
</ol>
<p>Something like this</p>
<p><a href="http://www.roberthorvick.com/images/CreatingaBudgetHomeRecordingStudio_14762/wheremusiccomesfrom.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="wheremusiccomesfrom" border="0" alt="wheremusiccomesfrom" src="http://www.roberthorvick.com/images/CreatingaBudgetHomeRecordingStudio_14762/wheremusiccomesfrom_thumb.png" width="314" height="182" /></a> </p>
<p>That’s one hell of an expensive question mark.</p>
<p>So over the next few posts (or weeks … who knows) I’ll be going over what I’m thinking about, what I decide, and why I changed my mind just minutes after making a decision after days of thinking.</p>



Share and Enjoy:


	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F13%252Fcreating-a-budget-home-recording-studio%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="twitter" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DCreating%2520a%2520Budget%2520Home%2520Recording%2520Studio%2520-%2520http%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F13%252Fcreating-a-budget-home-recording-studio%252F';" title="Twitter"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F13%252Fcreating-a-budget-home-recording-studio%252F%26amp%3Btitle%3DCreating%2520a%2520Budget%2520Home%2520Recording%2520Studio%26amp%3Bbodytext%3DI%25E2%2580%2599m%2520in%2520the%2520planning%2520stages%2520of%2520putting%2520together%2520a%2520home%2520recording%2520studio%2520for%2520capturing%2520the%2520musical%2520ideas%2520that%2520no%2520one%2520else%2520wants%2520to%2520hear.%2526%2523160%253B%2520In%2520high%2520school%2520I%2520spent%2520my%2520junior%2520year%2520at%2520the%2520Minnesota%2520Center%2520for%2520Arts%2520Education%2520%2528I%2520spent%2520my%2520senior%2520year%2520pr';" title="Digg"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="reddit" href="javascript:window.location='http%3A%2F%2Freddit.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F13%252Fcreating-a-budget-home-recording-studio%252F%26amp%3Btitle%3DCreating%2520a%2520Budget%2520Home%2520Recording%2520Studio';" title="Reddit"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F13%252Fcreating-a-budget-home-recording-studio%252F%26amp%3Btitle%3DCreating%2520a%2520Budget%2520Home%2520Recording%2520Studio%26amp%3Bnotes%3DI%25E2%2580%2599m%2520in%2520the%2520planning%2520stages%2520of%2520putting%2520together%2520a%2520home%2520recording%2520studio%2520for%2520capturing%2520the%2520musical%2520ideas%2520that%2520no%2520one%2520else%2520wants%2520to%2520hear.%2526%2523160%253B%2520In%2520high%2520school%2520I%2520spent%2520my%2520junior%2520year%2520at%2520the%2520Minnesota%2520Center%2520for%2520Arts%2520Education%2520%2528I%2520spent%2520my%2520senior%2520year%2520pr';" title="del.icio.us"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F13%252Fcreating-a-budget-home-recording-studio%252F%26amp%3Bt%3DCreating%2520a%2520Budget%2520Home%2520Recording%2520Studio';" title="Facebook"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F13%252Fcreating-a-budget-home-recording-studio%252F%26amp%3Btitle%3DCreating%2520a%2520Budget%2520Home%2520Recording%2520Studio%26amp%3Bannotation%3DI%25E2%2580%2599m%2520in%2520the%2520planning%2520stages%2520of%2520putting%2520together%2520a%2520home%2520recording%2520studio%2520for%2520capturing%2520the%2520musical%2520ideas%2520that%2520no%2520one%2520else%2520wants%2520to%2520hear.%2526%2523160%253B%2520In%2520high%2520school%2520I%2520spent%2520my%2520junior%2520year%2520at%2520the%2520Minnesota%2520Center%2520for%2520Arts%2520Education%2520%2528I%2520spent%2520my%2520senior%2520year%2520pr';" title="Google Bookmarks"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="stumbleupon" href="javascript:window.location='http%3A%2F%2Fwww.stumbleupon.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F08%252F13%252Fcreating-a-budget-home-recording-studio%252F%26amp%3Btitle%3DCreating%2520a%2520Budget%2520Home%2520Recording%2520Studio';" title="StumbleUpon"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.roberthorvick.com/2009/08/13/creating-a-budget-home-recording-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Syntax Highlighing for Erlang in NotePad++</title>
		<link>http://www.roberthorvick.com/2009/07/08/syntax-highlighing-for-erlang-in-notepad/</link>
		<comments>http://www.roberthorvick.com/2009/07/08/syntax-highlighing-for-erlang-in-notepad/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 18:02:42 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.roberthorvick.com/?p=64</guid>
		<description><![CDATA[Update: The definition has been updated to include support for atoms, variables and function names as well as additional file extensions.  Screen shot and downloadable content have been updated.
Thus far I&#8217;ve done all of my Erlang development on Fedora using vim or KWrite (which does a decent job in Ruby mode).
But today I found myself [...]]]></description>
			<content:encoded><![CDATA[<p><em>Update: The definition has been updated to include support for atoms, variables and function names as well as additional file extensions.  Screen shot and downloadable content have been updated.</em></p>
<p>Thus far I&#8217;ve done all of my Erlang development on Fedora using vim or KWrite (which does a decent job in Ruby mode).</p>
<p>But today I found myself on a windows box and wanted a basic syntax highlighting editor for Erlang that was free and worked on Windows.  Oh &#8211; and not Eclipse+Erlide.  I wanted something small and fast.</p>
<p>I grabbed the &#8220;<a href="http://en.wikipedia.org/wiki/Free_as_in_beer">free as in beer</a>&#8221; and &#8220;<a href="http://en.wikipedia.org/wiki/Free_as_in_beer#.22Free_as_in_beer.22_vs_.22Free_as_in_speech.22">free as in speech</a>&#8221; editor <a href="http://notepad-plus.sourceforge.net">NotePad++</a> and created a simple syntax file that is a bit hokey but will serve my needs fine.</p>
<p>Here&#8217;s a screen shot &#8230;<br />
<img class="aligncenter size-medium wp-image-65" title="Windows Erlang Syntax Highlighting Editor" src="http://www.roberthorvick.com/wp-content/uploads/2009/07/screenshot1.jpg" alt="Windows Erlang Syntax Highlighting Editor" width="550" height="449" /></p>
<p>NotePad++ has pretty weak syntax highlighting but was sufficent to do most of what I wanted.  Some regex based rules would make this a more robust.</p>
<p>Highlighted entities include</p>
<ul>
<li>Erlang reserved words (and named operators)</li>
<li>Variables</li>
<li>Atoms</li>
<li>function names (same coloring as atoms)</li>
<li>Operators</li>
<li>Comments</li>
<li>Kernal, stdlib, mnesia and odbc modules.</li>
<li>Support for *.erl, *.hrl and *.htp extentions</li>
</ul>
<p>I&#8217;ve probably missed several things.</p>
<p>Looks a lot better than nothing and it took all of <span style="text-decoration: line-through;">10</span> 15 minutes.</p>
<p>If you are using NotePad++ here is the file:</p>
<p><a href="http://www.roberthorvick.com/wp-content/uploads/2009/07/erlangSyntaxDefinition.zip">http://www.roberthorvick.com/wp-content/uploads/2009/07/erlangSyntaxDefinition.zip</a></p>
<p>And here are the instructions on how to install it:</p>
<p><a href="http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Syntax_Highlighting_Sharing">http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Syntax_Highlighting_Sharing</a></p>
<p>And here&#8217;s the instructions on modifying or creating your own:</p>
<p><a href="http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=User_Defined_Languages">http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=User_Defined_Languages</a></p>



Share and Enjoy:


	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F08%252Fsyntax-highlighing-for-erlang-in-notepad%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="twitter" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DSyntax%2520Highlighing%2520for%2520Erlang%2520in%2520NotePad%252B%252B%2520-%2520http%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F08%252Fsyntax-highlighing-for-erlang-in-notepad%252F';" title="Twitter"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F08%252Fsyntax-highlighing-for-erlang-in-notepad%252F%26amp%3Btitle%3DSyntax%2520Highlighing%2520for%2520Erlang%2520in%2520NotePad%252B%252B%26amp%3Bbodytext%3DUpdate%253A%2520The%2520definition%2520has%2520been%2520updated%2520to%2520include%2520support%2520for%2520atoms%252C%2520variables%2520and%2520function%2520names%2520as%2520well%2520as%2520additional%2520file%2520extensions.%2520%25C2%25A0Screen%2520shot%2520and%2520downloadable%2520content%2520have%2520been%2520updated.%250D%250A%250D%250AThus%2520far%2520I%2527ve%2520done%2520all%2520of%2520my%2520Erlang%2520development%2520on%2520';" title="Digg"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="reddit" href="javascript:window.location='http%3A%2F%2Freddit.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F08%252Fsyntax-highlighing-for-erlang-in-notepad%252F%26amp%3Btitle%3DSyntax%2520Highlighing%2520for%2520Erlang%2520in%2520NotePad%252B%252B';" title="Reddit"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F08%252Fsyntax-highlighing-for-erlang-in-notepad%252F%26amp%3Btitle%3DSyntax%2520Highlighing%2520for%2520Erlang%2520in%2520NotePad%252B%252B%26amp%3Bnotes%3DUpdate%253A%2520The%2520definition%2520has%2520been%2520updated%2520to%2520include%2520support%2520for%2520atoms%252C%2520variables%2520and%2520function%2520names%2520as%2520well%2520as%2520additional%2520file%2520extensions.%2520%25C2%25A0Screen%2520shot%2520and%2520downloadable%2520content%2520have%2520been%2520updated.%250D%250A%250D%250AThus%2520far%2520I%2527ve%2520done%2520all%2520of%2520my%2520Erlang%2520development%2520on%2520';" title="del.icio.us"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F08%252Fsyntax-highlighing-for-erlang-in-notepad%252F%26amp%3Bt%3DSyntax%2520Highlighing%2520for%2520Erlang%2520in%2520NotePad%252B%252B';" title="Facebook"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F08%252Fsyntax-highlighing-for-erlang-in-notepad%252F%26amp%3Btitle%3DSyntax%2520Highlighing%2520for%2520Erlang%2520in%2520NotePad%252B%252B%26amp%3Bannotation%3DUpdate%253A%2520The%2520definition%2520has%2520been%2520updated%2520to%2520include%2520support%2520for%2520atoms%252C%2520variables%2520and%2520function%2520names%2520as%2520well%2520as%2520additional%2520file%2520extensions.%2520%25C2%25A0Screen%2520shot%2520and%2520downloadable%2520content%2520have%2520been%2520updated.%250D%250A%250D%250AThus%2520far%2520I%2527ve%2520done%2520all%2520of%2520my%2520Erlang%2520development%2520on%2520';" title="Google Bookmarks"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="stumbleupon" href="javascript:window.location='http%3A%2F%2Fwww.stumbleupon.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F08%252Fsyntax-highlighing-for-erlang-in-notepad%252F%26amp%3Btitle%3DSyntax%2520Highlighing%2520for%2520Erlang%2520in%2520NotePad%252B%252B';" title="StumbleUpon"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.roberthorvick.com/2009/07/08/syntax-highlighing-for-erlang-in-notepad/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Startup and Cleanup functions in Erlang EUnit tests</title>
		<link>http://www.roberthorvick.com/2009/07/06/startup-and-cleanup-functions-in-erlang-eunit-tests/</link>
		<comments>http://www.roberthorvick.com/2009/07/06/startup-and-cleanup-functions-in-erlang-eunit-tests/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 04:22:16 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[eunit]]></category>

		<guid isPermaLink="false">http://www.roberthorvick.com/?p=62</guid>
		<description><![CDATA[I&#8217;ve got the basic grasp on Erlang but before I can do anything meaningful I need to learn how to test my code  EUnit is the de-facto test framework.  There are a ton of great sites that talk about testing with EUnit &#8211; I have linked to several at the end of this post.  I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve got the basic grasp on Erlang but before I can do anything meaningful I need to learn how to test my code  EUnit is the de-facto test framework.  There are a ton of great sites that talk about testing with EUnit &#8211; I have linked to several at the end of this post.  I&#8217;m going to focus on the problem I ran into &#8211; needing to run some startup and cleanup code around the test suite.</p>
<p>I started by writing a very simple dictionary that lived in it&#8217;s own process.  The interface is:</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #ff3c00;">start</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #006600;">ok</span>
<span style="color: #ff3c00;">stop</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #006600;">ok</span>
<span style="color: #ff3c00;">write</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Key</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Element</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #006600;">ok</span>
<span style="color: #ff3c00;">delete</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Key</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #006600;">ok</span>
<span style="color: #ff3c00;">read</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Key</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #109ab8;">&#123;</span>ok<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Value</span><span style="color: #109ab8;">&#125;</span> | not_found</pre></div></div>

<p>Calling start() spawns and registers the process the dictionary lives in.  Calling stop ends the process.  The rest do what you expect.</p>
<p>I started by writing some basic tests for each function but I didn&#8217;t really think it through.  The start test ran somewhere in the middle so all the tests prior to start either failed or timed out (because I was waiting on a receive that would never come since the process wasn&#8217;t started).  Very quickly I smacked my forehead and said &#8220;I need the test suite to have a pre and post function to start and stop the process&#8221;.</p>
<p>It took about 15 minutes of reading to realize that I needed to create a test generator with a setup tuple that defined the startup, cleanup and list of tests to run.</p>
<p>Conceptually it was easy to understand but getting the syntax right was a royal pain.  Basically you do this (I&#8217;m not sure if giving the function arity is the preferred method but it saved some keystrokes so I went with it):</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #ff3c00;">my_db_test_</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
  <span style="color: #109ab8;">&#123;</span>spawn<span style="color: #6bb810;">,</span>
    <span style="color: #109ab8;">&#123;</span>setup<span style="color: #6bb810;">,</span>
      <span style="color: #186895;">fun</span> start<span style="color: #014ea4;">/</span><span style="color: #ff9600;">0</span><span style="color: #6bb810;">,</span>
      <span style="color: #186895;">fun</span> stop<span style="color: #014ea4;">/</span><span style="color: #ff9600;">1</span><span style="color: #6bb810;">,</span>
      <span style="color: #109ab8;">&#91;</span>
        <span style="color: #186895;">fun</span> write_new<span style="color: #014ea4;">/</span><span style="color: #ff9600;">0</span><span style="color: #6bb810;">,</span>
        <span style="color: #186895;">fun</span> write_existing<span style="color: #014ea4;">/</span><span style="color: #ff9600;">0</span><span style="color: #6bb810;">,</span>
        <span style="color: #186895;">fun</span> read_existing<span style="color: #014ea4;">/</span><span style="color: #ff9600;">0</span><span style="color: #6bb810;">,</span>
        <span style="color: #186895;">fun</span> read_missing<span style="color: #014ea4;">/</span><span style="color: #ff9600;">0</span><span style="color: #6bb810;">,</span>
        <span style="color: #186895;">fun</span> delete_existing<span style="color: #014ea4;">/</span><span style="color: #ff9600;">0</span><span style="color: #6bb810;">,</span>
        <span style="color: #186895;">fun</span> delete_missing<span style="color: #014ea4;">/</span><span style="color: #ff9600;">0</span>
      <span style="color: #109ab8;">&#93;</span>
    <span style="color: #109ab8;">&#125;</span>
  <span style="color: #109ab8;">&#125;</span><span style="color: #6bb810;">.</span></pre></div></div>

<p>The test methods are exactly what you&#8217;d expect so I won&#8217;t repeat them.  The syntax feels a little foreign and uncomfortable but it&#8217;s very easy to understand and I totally get why it&#8217;s written this way.  I&#8217;m just so used to <a href="http://en.wikipedia.org/wiki/MSTest">MSTest</a> attributes and <a href="http://rspec.info/">RSpec</a> that this new way is going to take a night or two to feel like an old friend.</p>
<h2>Some Eunit resources</h2>
<p><a href="http://pragdave.pragprog.com/pragdave/2007/04/testfirst_word_.html">Prag Dave &#8211; Test-First Word Wrap in Erlang</a></p>
<p><a href="http://svn.process-one.net/contribs/trunk/eunit/doc/overview-summary.html">EUnit &#8211; a Lightweight Unit Testing Framework for Erlang</a></p>
<p><a href="http://erlang.org/doc/apps/eunit/index.html">EUnit Reference Manual</a></p>
<p><a href="http://salientblue.com/codenotes/?name=erl_start">Getting Started: No Consoles!</a></p>



Share and Enjoy:


	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F06%252Fstartup-and-cleanup-functions-in-erlang-eunit-tests%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="twitter" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DStartup%2520and%2520Cleanup%2520functions%2520in%2520Erlang%2520EUnit%2520tests%2520-%2520http%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F06%252Fstartup-and-cleanup-functions-in-erlang-eunit-tests%252F';" title="Twitter"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F06%252Fstartup-and-cleanup-functions-in-erlang-eunit-tests%252F%26amp%3Btitle%3DStartup%2520and%2520Cleanup%2520functions%2520in%2520Erlang%2520EUnit%2520tests%26amp%3Bbodytext%3DI%2527ve%2520got%2520the%2520basic%2520grasp%2520on%2520Erlang%2520but%2520before%2520I%2520can%2520do%2520anything%2520meaningful%2520I%2520need%2520to%2520learn%2520how%2520to%2520test%2520my%2520code%25C2%25A0%2520EUnit%2520is%2520the%2520de-facto%2520test%2520framework.%25C2%25A0%2520There%2520are%2520a%2520ton%2520of%2520great%2520sites%2520that%2520talk%2520about%2520testing%2520with%2520EUnit%2520-%2520I%2520have%2520linked%2520to%2520several%2520at%2520t';" title="Digg"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="reddit" href="javascript:window.location='http%3A%2F%2Freddit.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F06%252Fstartup-and-cleanup-functions-in-erlang-eunit-tests%252F%26amp%3Btitle%3DStartup%2520and%2520Cleanup%2520functions%2520in%2520Erlang%2520EUnit%2520tests';" title="Reddit"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F06%252Fstartup-and-cleanup-functions-in-erlang-eunit-tests%252F%26amp%3Btitle%3DStartup%2520and%2520Cleanup%2520functions%2520in%2520Erlang%2520EUnit%2520tests%26amp%3Bnotes%3DI%2527ve%2520got%2520the%2520basic%2520grasp%2520on%2520Erlang%2520but%2520before%2520I%2520can%2520do%2520anything%2520meaningful%2520I%2520need%2520to%2520learn%2520how%2520to%2520test%2520my%2520code%25C2%25A0%2520EUnit%2520is%2520the%2520de-facto%2520test%2520framework.%25C2%25A0%2520There%2520are%2520a%2520ton%2520of%2520great%2520sites%2520that%2520talk%2520about%2520testing%2520with%2520EUnit%2520-%2520I%2520have%2520linked%2520to%2520several%2520at%2520t';" title="del.icio.us"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F06%252Fstartup-and-cleanup-functions-in-erlang-eunit-tests%252F%26amp%3Bt%3DStartup%2520and%2520Cleanup%2520functions%2520in%2520Erlang%2520EUnit%2520tests';" title="Facebook"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F06%252Fstartup-and-cleanup-functions-in-erlang-eunit-tests%252F%26amp%3Btitle%3DStartup%2520and%2520Cleanup%2520functions%2520in%2520Erlang%2520EUnit%2520tests%26amp%3Bannotation%3DI%2527ve%2520got%2520the%2520basic%2520grasp%2520on%2520Erlang%2520but%2520before%2520I%2520can%2520do%2520anything%2520meaningful%2520I%2520need%2520to%2520learn%2520how%2520to%2520test%2520my%2520code%25C2%25A0%2520EUnit%2520is%2520the%2520de-facto%2520test%2520framework.%25C2%25A0%2520There%2520are%2520a%2520ton%2520of%2520great%2520sites%2520that%2520talk%2520about%2520testing%2520with%2520EUnit%2520-%2520I%2520have%2520linked%2520to%2520several%2520at%2520t';" title="Google Bookmarks"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="stumbleupon" href="javascript:window.location='http%3A%2F%2Fwww.stumbleupon.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F06%252Fstartup-and-cleanup-functions-in-erlang-eunit-tests%252F%26amp%3Btitle%3DStartup%2520and%2520Cleanup%2520functions%2520in%2520Erlang%2520EUnit%2520tests';" title="StumbleUpon"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.roberthorvick.com/2009/07/06/startup-and-cleanup-functions-in-erlang-eunit-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The last word frequency post &#8211; from dict to ets</title>
		<link>http://www.roberthorvick.com/2009/07/03/the-last-word-frequency-post-from-dict-to-ets/</link>
		<comments>http://www.roberthorvick.com/2009/07/03/the-last-word-frequency-post-from-dict-to-ets/#comments</comments>
		<pubDate>Sat, 04 Jul 2009 03:15:56 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[ets]]></category>

		<guid isPermaLink="false">http://www.roberthorvick.com/?p=57</guid>
		<description><![CDATA[One last iteration through my learning exercise of building a word frequency list.  In this last post I&#8217;m moving away from a dict and to an ets table.  I was pleasantly surprised how easy the conversion was.  For example printing the output was just converting from dict:fold to ets:foldl.  The one [...]]]></description>
			<content:encoded><![CDATA[<p>One last iteration through my learning exercise of building a word frequency list.  In this last post I&#8217;m moving away from a dict and to an ets table.  I was pleasantly surprised how easy the conversion was.  For example printing the output was just converting from dict:fold to ets:foldl.  The one parity fail was that dict:update can take an initial value when the key is missing but ets:update_counter (nor any other ets function) has this benefit.  This required that I write a little wrapper function to call from the list:foldl (instead of having a multi-line inlined fun).</p>
<p>No point in getting too deep into this &#8211; here&#8217;s the code:</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #014ea4;">-</span><span style="color: #5400b3;">module</span><span style="color: #109ab8;">&#40;</span>wordets<span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #014ea4;">-</span><span style="color: #5400b3;">export</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span>print_word_counts<span style="color: #014ea4;">/</span><span style="color: #ff9600;">1</span><span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #ff3c00;">words</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">String</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
  <span style="color: #109ab8;">&#123;</span>match<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Captures</span><span style="color: #109ab8;">&#125;</span> <span style="color: #014ea4;">=</span> <span style="color: #ff4e18;">re</span>:<span style="color: #ff3c00;">run</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">String</span><span style="color: #6bb810;">,</span> <span style="color: #ff7800;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>b<span style="color: #000099; font-weight: bold;">\\</span>w+<span style="color: #000099; font-weight: bold;">\\</span>b&quot;</span><span style="color: #6bb810;">,</span> <span style="color: #109ab8;">&#91;</span>global<span style="color: #6bb810;">,</span><span style="color: #109ab8;">&#123;</span>capture<span style="color: #6bb810;">,</span>first<span style="color: #6bb810;">,</span><span style="color: #fa6fff;">list</span><span style="color: #109ab8;">&#125;</span><span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
  <span style="color: #ff4e18;">lists</span>:<span style="color: #ff3c00;">append</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Captures</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #666666; font-style: italic;">%% reads the next line from the file.  If there is data then...</span>
<span style="color: #666666; font-style: italic;">%% split the data into a list of words and add to the word table</span>
<span style="color: #ff3c00;">process_each_line</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">IoDevice</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Table</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
  <span style="color: #186895;">case</span> <span style="color: #ff4e18;">io</span>:<span style="color: #ff3c00;">get_line</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">IoDevice</span><span style="color: #6bb810;">,</span> <span style="color: #ff7800;">&quot;&quot;</span><span style="color: #109ab8;">&#41;</span> <span style="color: #186895;">of</span>
    eof <span style="color: #6bb810;">-&gt;</span> 
      <span style="color: #ff4e18;">file</span>:<span style="color: #ff3c00;">close</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">IoDevice</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
      <span style="color: #45b3e6;">Table</span><span style="color: #6bb810;">;</span>
    <span style="color: #109ab8;">&#123;</span>error<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Reason</span><span style="color: #109ab8;">&#125;</span> <span style="color: #6bb810;">-&gt;</span>
      <span style="color: #ff4e18;">file</span>:<span style="color: #ff3c00;">close</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">IoDevice</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
      <span style="color: #ff3c00;">throw</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Reason</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">;</span>
    <span style="color: #45b3e6;">Data</span> <span style="color: #6bb810;">-&gt;</span>
      <span style="color: #45b3e6;">NewTable</span> <span style="color: #014ea4;">=</span> <span style="color: #ff4e18;">lists</span>:<span style="color: #ff3c00;">foldl</span><span style="color: #109ab8;">&#40;</span>
        <span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">W</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">T</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #ff3c00;">update_word_count</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">W</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">T</span><span style="color: #109ab8;">&#41;</span> <span style="color: #186895;">end</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Table</span><span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">words</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Data</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
      <span style="color: #ff3c00;">process_each_line</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">IoDevice</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">NewTable</span><span style="color: #109ab8;">&#41;</span>
  <span style="color: #186895;">end</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #ff3c00;">update_word_count</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Word</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Table</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
  <span style="color: #186895;">case</span> <span style="color: #ff4e18;">ets</span>:<span style="color: #ff3c00;">lookup</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Table</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Word</span><span style="color: #109ab8;">&#41;</span> <span style="color: #186895;">of</span>
    <span style="color: #109ab8;">&#91;</span><span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">Word</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">_</span><span style="color: #109ab8;">&#125;</span><span style="color: #109ab8;">&#93;</span> <span style="color: #6bb810;">-&gt;</span>
      <span style="color: #ff4e18;">ets</span>:<span style="color: #ff3c00;">update_counter</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Table</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Word</span><span style="color: #6bb810;">,</span> <span style="color: #ff9600;">1</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">;</span> 
    <span style="color: #109ab8;">&#91;</span><span style="color: #109ab8;">&#93;</span> <span style="color: #6bb810;">-&gt;</span>
      <span style="color: #ff4e18;">ets</span>:<span style="color: #ff3c00;">insert</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Table</span><span style="color: #6bb810;">,</span> <span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">Word</span><span style="color: #6bb810;">,</span> <span style="color: #ff9600;">1</span><span style="color: #109ab8;">&#125;</span><span style="color: #109ab8;">&#41;</span>
  <span style="color: #186895;">end</span><span style="color: #6bb810;">,</span>
  <span style="color: #45b3e6;">Table</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #ff3c00;">print_words</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Words</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
  <span style="color: #ff4e18;">ets</span>:<span style="color: #ff3c00;">foldl</span><span style="color: #109ab8;">&#40;</span><span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">W</span><span style="color: #6bb810;">,</span><span style="color: #45b3e6;">C</span><span style="color: #109ab8;">&#125;</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">AccIn</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> 
    <span style="color: #ff4e18;">io</span>:<span style="color: #ff3c00;">format</span><span style="color: #109ab8;">&#40;</span><span style="color: #ff7800;">&quot;~s: ~w~n&quot;</span><span style="color: #6bb810;">,</span> <span style="color: #109ab8;">&#91;</span><span style="color: #45b3e6;">W</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">C</span><span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">AccIn</span> <span style="color: #186895;">end</span><span style="color: #6bb810;">,</span> void<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Words</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #666666; font-style: italic;">%% opens the indicated file, processes the contents and prints</span>
<span style="color: #666666; font-style: italic;">%% out the word/count pairs to stdout</span>
<span style="color: #ff3c00;">print_word_counts</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Filename</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
  <span style="color: #109ab8;">&#123;</span>ok<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">IoDevice</span><span style="color: #109ab8;">&#125;</span> <span style="color: #014ea4;">=</span> <span style="color: #ff4e18;">file</span>:<span style="color: #ff3c00;">open</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Filename</span><span style="color: #6bb810;">,</span> read<span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
  <span style="color: #45b3e6;">Words</span> <span style="color: #014ea4;">=</span> <span style="color: #ff3c00;">process_each_line</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">IoDevice</span><span style="color: #6bb810;">,</span> <span style="color: #ff4e18;">ets</span>:<span style="color: #ff3c00;">new</span><span style="color: #109ab8;">&#40;</span>words<span style="color: #6bb810;">,</span> <span style="color: #109ab8;">&#91;</span><span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
  <span style="color: #ff3c00;">print_words</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Words</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span></pre></div></div>

<p>The ets implementation feels a bit forced (which it was &#8211; the point was to learn another module).  I don&#8217;t think I&#8217;d have gone this way in practice unless I wanted to persist the frequency data to a file or if the word data were more complex (for example if I were storing information about where in the file the word was, word neighbors, etc).</p>
<p>Enough of this sample.  On to something more substantial.</p>



Share and Enjoy:


	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F03%252Fthe-last-word-frequency-post-from-dict-to-ets%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="twitter" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DThe%2520last%2520word%2520frequency%2520post%2520-%2520from%2520dict%2520to%2520ets%2520-%2520http%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F03%252Fthe-last-word-frequency-post-from-dict-to-ets%252F';" title="Twitter"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F03%252Fthe-last-word-frequency-post-from-dict-to-ets%252F%26amp%3Btitle%3DThe%2520last%2520word%2520frequency%2520post%2520-%2520from%2520dict%2520to%2520ets%26amp%3Bbodytext%3DOne%2520last%2520iteration%2520through%2520my%2520learning%2520exercise%2520of%2520building%2520a%2520word%2520frequency%2520list.%2520%2520In%2520this%2520last%2520post%2520I%2527m%2520moving%2520away%2520from%2520a%2520dict%2520and%2520to%2520an%2520ets%2520table.%2520%2520I%2520was%2520pleasantly%2520surprised%2520how%2520easy%2520the%2520conversion%2520was.%2520%2520For%2520example%2520printing%2520the%2520output%2520was%2520just%2520';" title="Digg"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="reddit" href="javascript:window.location='http%3A%2F%2Freddit.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F03%252Fthe-last-word-frequency-post-from-dict-to-ets%252F%26amp%3Btitle%3DThe%2520last%2520word%2520frequency%2520post%2520-%2520from%2520dict%2520to%2520ets';" title="Reddit"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F03%252Fthe-last-word-frequency-post-from-dict-to-ets%252F%26amp%3Btitle%3DThe%2520last%2520word%2520frequency%2520post%2520-%2520from%2520dict%2520to%2520ets%26amp%3Bnotes%3DOne%2520last%2520iteration%2520through%2520my%2520learning%2520exercise%2520of%2520building%2520a%2520word%2520frequency%2520list.%2520%2520In%2520this%2520last%2520post%2520I%2527m%2520moving%2520away%2520from%2520a%2520dict%2520and%2520to%2520an%2520ets%2520table.%2520%2520I%2520was%2520pleasantly%2520surprised%2520how%2520easy%2520the%2520conversion%2520was.%2520%2520For%2520example%2520printing%2520the%2520output%2520was%2520just%2520';" title="del.icio.us"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F03%252Fthe-last-word-frequency-post-from-dict-to-ets%252F%26amp%3Bt%3DThe%2520last%2520word%2520frequency%2520post%2520-%2520from%2520dict%2520to%2520ets';" title="Facebook"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F03%252Fthe-last-word-frequency-post-from-dict-to-ets%252F%26amp%3Btitle%3DThe%2520last%2520word%2520frequency%2520post%2520-%2520from%2520dict%2520to%2520ets%26amp%3Bannotation%3DOne%2520last%2520iteration%2520through%2520my%2520learning%2520exercise%2520of%2520building%2520a%2520word%2520frequency%2520list.%2520%2520In%2520this%2520last%2520post%2520I%2527m%2520moving%2520away%2520from%2520a%2520dict%2520and%2520to%2520an%2520ets%2520table.%2520%2520I%2520was%2520pleasantly%2520surprised%2520how%2520easy%2520the%2520conversion%2520was.%2520%2520For%2520example%2520printing%2520the%2520output%2520was%2520just%2520';" title="Google Bookmarks"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="stumbleupon" href="javascript:window.location='http%3A%2F%2Fwww.stumbleupon.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F03%252Fthe-last-word-frequency-post-from-dict-to-ets%252F%26amp%3Btitle%3DThe%2520last%2520word%2520frequency%2520post%2520-%2520from%2520dict%2520to%2520ets';" title="StumbleUpon"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.roberthorvick.com/2009/07/03/the-last-word-frequency-post-from-dict-to-ets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding a custom protocol to Firefox for easy Erlang docs</title>
		<link>http://www.roberthorvick.com/2009/07/03/adding-a-custom-protocol-to-firefox-for-easy-erlang-docs/</link>
		<comments>http://www.roberthorvick.com/2009/07/03/adding-a-custom-protocol-to-firefox-for-easy-erlang-docs/#comments</comments>
		<pubDate>Sat, 04 Jul 2009 01:11:43 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[Erlang]]></category>

		<guid isPermaLink="false">http://www.roberthorvick.com/?p=50</guid>
		<description><![CDATA[To make getting to the Erlang docs a bit quicker I added a custom protocol handler to firefox so when I go to:
erlang://lists
I get redirected to
http://www.erlang.org/doc/man/lists.html
To do this I first created a little shell script that would take the address and spawn firefox with the appropriate url.  (insert caveat about this being the first [...]]]></description>
			<content:encoded><![CDATA[<p>To make getting to the Erlang docs a bit quicker I added a custom protocol handler to firefox so when I go to:</p>
<p><a href="erlang://lists">erlang://lists</a></p>
<p>I get redirected to</p>
<p><a href="http://www.erlang.org/doc/man/lists.html">http://www.erlang.org/doc/man/lists.html</a></p>
<p>To do this I first created a little shell script that would take the address and spawn firefox with the appropriate url.  (insert caveat about this being the first bash script I&#8217;ve written in 10 years here &#8230;).</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">ERLANG_TOPIC</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> $<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/erlang:\/\///'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #7a0874; font-weight: bold;">exec</span> firefox http:<span style="color: #000000; font-weight: bold;">//</span>www.erlang.org<span style="color: #000000; font-weight: bold;">/</span>doc<span style="color: #000000; font-weight: bold;">/</span>man<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$ERLANG_TOPIC</span>.html</pre></div></div>

<p>Next I marked it as executable:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> +x erlang.protocol</pre></div></div>

<p>Finally I followed <a href="http://kb.mozillazine.org/Register_protocol">these directions</a> and added the following config settings in firefox:</p>
<p><img class="aligncenter size-full wp-image-52" title="Adding custom protocol to firefox" src="http://www.roberthorvick.com/wp-content/uploads/2009/07/aboutconfig.png" alt="Adding custom protocol to firefox" width="774" height="137" /></p>
<p>Since the Erlang/OTP doc pages match their module names this works pretty well.</p>
<p>For queries where I&#8217;m not sure what I want I added a Erlang specific google search to my <a href="http://www.roberthorvick.com/erlang-resources/">Erlang Resources</a> page.</p>



Share and Enjoy:


	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F03%252Fadding-a-custom-protocol-to-firefox-for-easy-erlang-docs%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="twitter" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DAdding%2520a%2520custom%2520protocol%2520to%2520Firefox%2520for%2520easy%2520Erlang%2520docs%2520-%2520http%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F03%252Fadding-a-custom-protocol-to-firefox-for-easy-erlang-docs%252F';" title="Twitter"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F03%252Fadding-a-custom-protocol-to-firefox-for-easy-erlang-docs%252F%26amp%3Btitle%3DAdding%2520a%2520custom%2520protocol%2520to%2520Firefox%2520for%2520easy%2520Erlang%2520docs%26amp%3Bbodytext%3DTo%2520make%2520getting%2520to%2520the%2520Erlang%2520docs%2520a%2520bit%2520quicker%2520I%2520added%2520a%2520custom%2520protocol%2520handler%2520to%2520firefox%2520so%2520when%2520I%2520go%2520to%253A%250D%250A%250D%250Aerlang%253A%252F%252Flists%250D%250A%250D%250AI%2520get%2520redirected%2520to%250D%250A%250D%250Ahttp%253A%252F%252Fwww.erlang.org%252Fdoc%252Fman%252Flists.html%250D%250A%250D%250ATo%2520do%2520this%2520I%2520first%2520created%2520a%2520little%2520shell%2520script%2520th';" title="Digg"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="reddit" href="javascript:window.location='http%3A%2F%2Freddit.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F03%252Fadding-a-custom-protocol-to-firefox-for-easy-erlang-docs%252F%26amp%3Btitle%3DAdding%2520a%2520custom%2520protocol%2520to%2520Firefox%2520for%2520easy%2520Erlang%2520docs';" title="Reddit"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F03%252Fadding-a-custom-protocol-to-firefox-for-easy-erlang-docs%252F%26amp%3Btitle%3DAdding%2520a%2520custom%2520protocol%2520to%2520Firefox%2520for%2520easy%2520Erlang%2520docs%26amp%3Bnotes%3DTo%2520make%2520getting%2520to%2520the%2520Erlang%2520docs%2520a%2520bit%2520quicker%2520I%2520added%2520a%2520custom%2520protocol%2520handler%2520to%2520firefox%2520so%2520when%2520I%2520go%2520to%253A%250D%250A%250D%250Aerlang%253A%252F%252Flists%250D%250A%250D%250AI%2520get%2520redirected%2520to%250D%250A%250D%250Ahttp%253A%252F%252Fwww.erlang.org%252Fdoc%252Fman%252Flists.html%250D%250A%250D%250ATo%2520do%2520this%2520I%2520first%2520created%2520a%2520little%2520shell%2520script%2520th';" title="del.icio.us"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F03%252Fadding-a-custom-protocol-to-firefox-for-easy-erlang-docs%252F%26amp%3Bt%3DAdding%2520a%2520custom%2520protocol%2520to%2520Firefox%2520for%2520easy%2520Erlang%2520docs';" title="Facebook"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F03%252Fadding-a-custom-protocol-to-firefox-for-easy-erlang-docs%252F%26amp%3Btitle%3DAdding%2520a%2520custom%2520protocol%2520to%2520Firefox%2520for%2520easy%2520Erlang%2520docs%26amp%3Bannotation%3DTo%2520make%2520getting%2520to%2520the%2520Erlang%2520docs%2520a%2520bit%2520quicker%2520I%2520added%2520a%2520custom%2520protocol%2520handler%2520to%2520firefox%2520so%2520when%2520I%2520go%2520to%253A%250D%250A%250D%250Aerlang%253A%252F%252Flists%250D%250A%250D%250AI%2520get%2520redirected%2520to%250D%250A%250D%250Ahttp%253A%252F%252Fwww.erlang.org%252Fdoc%252Fman%252Flists.html%250D%250A%250D%250ATo%2520do%2520this%2520I%2520first%2520created%2520a%2520little%2520shell%2520script%2520th';" title="Google Bookmarks"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="stumbleupon" href="javascript:window.location='http%3A%2F%2Fwww.stumbleupon.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F03%252Fadding-a-custom-protocol-to-firefox-for-easy-erlang-docs%252F%26amp%3Btitle%3DAdding%2520a%2520custom%2520protocol%2520to%2520Firefox%2520for%2520easy%2520Erlang%2520docs';" title="StumbleUpon"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.roberthorvick.com/2009/07/03/adding-a-custom-protocol-to-firefox-for-easy-erlang-docs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Word frequency redux &#8211; Erlang list comprehension, regex and list folding</title>
		<link>http://www.roberthorvick.com/2009/07/02/word-frequency-redux-erlang-list-comprehension-regex-and-list-folding/</link>
		<comments>http://www.roberthorvick.com/2009/07/02/word-frequency-redux-erlang-list-comprehension-regex-and-list-folding/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 21:28:10 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[Erlang]]></category>

		<guid isPermaLink="false">http://www.roberthorvick.com/?p=41</guid>
		<description><![CDATA[Sean Cribbs was nice enough to point out a pair of changes I could make to my word frequency counter from last time.
Based on his feedback I made three changes.  First &#8211; the regular expression code has changed from this:

matches&#40;H,&#123;match,M&#125;&#41; -&#62; matches&#40;H,M,&#91;&#93;&#41;.
matches&#40;_,&#91;&#93;,Acc&#41; -&#62; Acc;
matches&#40;H,&#91;&#123;I,L&#125;&#124;T&#93;,Acc&#41; -&#62;
    matches&#40;H,T,&#91;lists:sublist&#40;H,I,L&#41;&#124;Acc&#93;&#41;.
&#160;
words&#40;String&#41; -&#62; matches&#40;String,regexp:matches&#40;String, &#34;[A-Za-z0-1]+&#34;&#41;&#41;.

to this:

words&#40;String&#41; -&#62;
 [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://seancribbs.com/">Sean Cribbs</a> was nice enough to <a href="http://www.roberthorvick.com/2009/07/02/finding-word-frequencies-using-erlang/#comments">point out</a> a pair of changes I could make to my <a href="http://www.roberthorvick.com/2009/07/02/finding-word-frequencies-using-erlang/">word frequency counter</a> from last time.</p>
<p>Based on his feedback I made three changes.  First &#8211; the regular expression code has changed from this:</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #ff3c00;">matches</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">H</span><span style="color: #6bb810;">,</span><span style="color: #109ab8;">&#123;</span>match<span style="color: #6bb810;">,</span><span style="color: #45b3e6;">M</span><span style="color: #109ab8;">&#125;</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #ff3c00;">matches</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">H</span><span style="color: #6bb810;">,</span><span style="color: #45b3e6;">M</span><span style="color: #6bb810;">,</span><span style="color: #109ab8;">&#91;</span><span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
<span style="color: #ff3c00;">matches</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">_</span><span style="color: #6bb810;">,</span><span style="color: #109ab8;">&#91;</span><span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">,</span><span style="color: #45b3e6;">Acc</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #45b3e6;">Acc</span><span style="color: #6bb810;">;</span>
<span style="color: #ff3c00;">matches</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">H</span><span style="color: #6bb810;">,</span><span style="color: #109ab8;">&#91;</span><span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">I</span><span style="color: #6bb810;">,</span><span style="color: #45b3e6;">L</span><span style="color: #109ab8;">&#125;</span>|T<span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">,</span><span style="color: #45b3e6;">Acc</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
    <span style="color: #ff3c00;">matches</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">H</span><span style="color: #6bb810;">,</span><span style="color: #45b3e6;">T</span><span style="color: #6bb810;">,</span><span style="color: #109ab8;">&#91;</span><span style="color: #ff4e18;">lists</span>:<span style="color: #ff3c00;">sublist</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">H</span><span style="color: #6bb810;">,</span><span style="color: #45b3e6;">I</span><span style="color: #6bb810;">,</span><span style="color: #45b3e6;">L</span><span style="color: #109ab8;">&#41;</span>|Acc<span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #ff3c00;">words</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">String</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #ff3c00;">matches</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">String</span><span style="color: #6bb810;">,</span><span style="color: #ff4e18;">regexp</span>:<span style="color: #ff3c00;">matches</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">String</span><span style="color: #6bb810;">,</span> <span style="color: #ff7800;">&quot;[A-Za-z0-1]+&quot;</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span></pre></div></div>

<p>to this:</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #ff3c00;">words</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">String</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
  <span style="color: #109ab8;">&#123;</span>match<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Captures</span><span style="color: #109ab8;">&#125;</span> <span style="color: #014ea4;">=</span> <span style="color: #ff4e18;">re</span>:<span style="color: #ff3c00;">run</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">String</span><span style="color: #6bb810;">,</span> <span style="color: #ff7800;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>b<span style="color: #000099; font-weight: bold;">\\</span>w+<span style="color: #000099; font-weight: bold;">\\</span>b&quot;</span><span style="color: #6bb810;">,</span> <span style="color: #109ab8;">&#91;</span>global<span style="color: #6bb810;">,</span><span style="color: #109ab8;">&#123;</span>capture<span style="color: #6bb810;">,</span>first<span style="color: #6bb810;">,</span><span style="color: #fa6fff;">list</span><span style="color: #109ab8;">&#125;</span><span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
  <span style="color: #109ab8;">&#91;</span><span style="color: #ff3c00;">hd</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">C</span><span style="color: #109ab8;">&#41;</span> <span style="color: #014ea4;">||</span> <span style="color: #45b3e6;">C</span><span style="color: #014ea4;">&lt;-</span><span style="color: #45b3e6;">Captures</span><span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">.</span></pre></div></div>

<p>That last line took me a bit to grok.  It&#8217;s a <a href="http://wiki.trapexit.org/List_Comprehension">list comprehension</a> (if you are reading Joe Armstrong&#8217;s <a href="http://www.sics.se/~joe/thesis/armstrong_thesis_2003.pdf">thesis</a> it is section 3.3.13.  In Erlang Programming it is chapter 9.3).  Basically it&#8217;s saying &#8220;for each list in the list of matches take the head of the list&#8221; &#8211; a-gigga-wah?</p>
<p>Ok.  Let&#8217;s go to erl.<br />
<code>7&gt; re:run("foo foo bar", "\\b\\w+\\b", [global,{capture,first,list}]).<br />
{match,[["foo"],["foo"],["bar"]]}</code><br />
Observe that re:run returns a nested list (i.e. a list of lists) &#8211; and each list has exactly one element (the string [which is itself a list but I'll cal them strings]).  What we want to do is take that list-of-lists-of-strings and turn it into a list-of-strings.</p>
<p>That&#8217;s what &#8220;[hd(C) || C&lt;-Captures].&#8221; does  &#8211; it pulls every capture (a word wrapped in a list) from the match list and runs it through erlang:hd which pulls the word from the list &#8211; then it gets added to the resulting list.  So we end up with a list strings.</p>
<p>It&#8217;s un-nesting the list.</p>
<p>Next Sean suggested <em>&#8220;Then I’d probably use some kind of key-value structure, like a proplist or dict, to count the words using a lists:foldX function.&#8221;</em></p>
<p>so I fired up &#8220;erl -man lists&#8221; to learn what foldX meant (actually &#8220;foldl&#8221; &#8220;foldr&#8221; depending on whether you want to fold from the left or right.</p>
<p>In a nut shell folding is iterates over a list calling a fun that takes the current value and an accumulator and which returns the new accumulator.  An example from the man page is:</p>
<p><code><br />
&gt; lists:foldl(fun(X, Sum) -&gt; X + Sum end, 0, [1,2,3,4,5]).<br />
15<br />
</code></p>
<p>I spent some time thinking and after some trial and error came up with this:</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #ff4e18;">lists</span>:<span style="color: #ff3c00;">foldl</span><span style="color: #109ab8;">&#40;</span><span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">W</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Dict</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> 
    <span style="color: #ff4e18;">dict</span>:<span style="color: #ff3c00;">update</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">W</span><span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">C</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #45b3e6;">C</span> <span style="color: #014ea4;">+</span> <span style="color: #ff9600;">1</span> <span style="color: #186895;">end</span><span style="color: #6bb810;">,</span> <span style="color: #ff9600;">1</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Dict</span><span style="color: #109ab8;">&#41;</span> <span style="color: #186895;">end</span><span style="color: #6bb810;">,</span> <span style="color: #ff4e18;">dict</span>:<span style="color: #ff3c00;">new</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span> 
    <span style="color: #109ab8;">&#91;</span><span style="color: #ff7800;">&quot;foo&quot;</span><span style="color: #6bb810;">,</span> <span style="color: #ff7800;">&quot;foo&quot;</span><span style="color: #6bb810;">,</span> <span style="color: #ff7800;">&quot;bar&quot;</span><span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>  <span style="color: #666666; font-style: italic;">%% sample input</span></pre></div></div>

<p>In a nutshell &#8211; for every word in the list update the dictionary by calling the fun which increments the count value, setting the initial count to 1 if the value does not already exist in the dictionary (and starting with an empty dictionary).</p>
<p>After these three changes the new program is about half the size of the previous and really only has a few interesting lines surround by nearly error and flow control.</p>
<p><strong>Thanks Sean!</strong></p>
<p>The new code &#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #014ea4;">-</span><span style="color: #5400b3;">module</span><span style="color: #109ab8;">&#40;</span>wordlist<span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #014ea4;">-</span><span style="color: #5400b3;">export</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span>print_word_counts<span style="color: #014ea4;">/</span><span style="color: #ff9600;">1</span><span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #ff3c00;">words</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">String</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
  <span style="color: #109ab8;">&#123;</span>match<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Captures</span><span style="color: #109ab8;">&#125;</span> <span style="color: #014ea4;">=</span> <span style="color: #ff4e18;">re</span>:<span style="color: #ff3c00;">run</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">String</span><span style="color: #6bb810;">,</span> <span style="color: #ff7800;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>b<span style="color: #000099; font-weight: bold;">\\</span>w+<span style="color: #000099; font-weight: bold;">\\</span>b&quot;</span><span style="color: #6bb810;">,</span> <span style="color: #109ab8;">&#91;</span>global<span style="color: #6bb810;">,</span><span style="color: #109ab8;">&#123;</span>capture<span style="color: #6bb810;">,</span>first<span style="color: #6bb810;">,</span><span style="color: #fa6fff;">list</span><span style="color: #109ab8;">&#125;</span><span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
  <span style="color: #109ab8;">&#91;</span><span style="color: #ff3c00;">hd</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">C</span><span style="color: #109ab8;">&#41;</span> <span style="color: #014ea4;">||</span> <span style="color: #45b3e6;">C</span><span style="color: #014ea4;">&lt;-</span><span style="color: #45b3e6;">Captures</span><span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #666666; font-style: italic;">%% reads the next line from the file.  If there is data then...</span>
<span style="color: #666666; font-style: italic;">%% split the data into a list of words and add those to the word dict</span>
<span style="color: #ff3c00;">process_each_line</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">IoDevice</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Dict</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
    <span style="color: #186895;">case</span> <span style="color: #ff4e18;">io</span>:<span style="color: #ff3c00;">get_line</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">IoDevice</span><span style="color: #6bb810;">,</span> <span style="color: #ff7800;">&quot;&quot;</span><span style="color: #109ab8;">&#41;</span> <span style="color: #186895;">of</span>
        eof <span style="color: #6bb810;">-&gt;</span> 
            <span style="color: #ff4e18;">file</span>:<span style="color: #ff3c00;">close</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">IoDevice</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
            <span style="color: #45b3e6;">Dict</span><span style="color: #6bb810;">;</span>
        <span style="color: #109ab8;">&#123;</span>error<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Reason</span><span style="color: #109ab8;">&#125;</span> <span style="color: #6bb810;">-&gt;</span>
            <span style="color: #ff4e18;">file</span>:<span style="color: #ff3c00;">close</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">IoDevice</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
            <span style="color: #ff3c00;">throw</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Reason</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">;</span>
        <span style="color: #45b3e6;">Data</span> <span style="color: #6bb810;">-&gt;</span>
            <span style="color: #45b3e6;">NewDict</span> <span style="color: #014ea4;">=</span> <span style="color: #ff4e18;">lists</span>:<span style="color: #ff3c00;">foldl</span><span style="color: #109ab8;">&#40;</span>
                        <span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">W</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">D</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #ff4e18;">dict</span>:<span style="color: #ff3c00;">update</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">W</span><span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">C</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #45b3e6;">C</span> <span style="color: #014ea4;">+</span> <span style="color: #ff9600;">1</span> <span style="color: #186895;">end</span><span style="color: #6bb810;">,</span> <span style="color: #ff9600;">1</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">D</span><span style="color: #109ab8;">&#41;</span> <span style="color: #186895;">end</span><span style="color: #6bb810;">,</span> 
                        <span style="color: #ff4e18;">dict</span>:<span style="color: #ff3c00;">new</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span> 
                        <span style="color: #ff3c00;">words</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Data</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
            <span style="color: #ff3c00;">process_each_line</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">IoDevice</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">NewDict</span><span style="color: #109ab8;">&#41;</span>
    <span style="color: #186895;">end</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #ff3c00;">print_dict</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Dict</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
    <span style="color: #ff4e18;">dict</span>:<span style="color: #ff3c00;">fold</span><span style="color: #109ab8;">&#40;</span><span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Word</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Count</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">AccIn</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> 
        <span style="color: #ff4e18;">io</span>:<span style="color: #ff3c00;">format</span><span style="color: #109ab8;">&#40;</span><span style="color: #ff7800;">&quot;~s: ~w~n&quot;</span><span style="color: #6bb810;">,</span> <span style="color: #109ab8;">&#91;</span><span style="color: #45b3e6;">Word</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Count</span><span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">AccIn</span> <span style="color: #186895;">end</span><span style="color: #6bb810;">,</span> void<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Dict</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #666666; font-style: italic;">%% opens the indicated file, processes the contents and prints</span>
<span style="color: #666666; font-style: italic;">%% out the word/count pairs to stdout</span>
<span style="color: #ff3c00;">print_word_counts</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Filename</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
    <span style="color: #186895;">case</span> <span style="color: #ff4e18;">file</span>:<span style="color: #ff3c00;">open</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Filename</span><span style="color: #6bb810;">,</span> read<span style="color: #109ab8;">&#41;</span> <span style="color: #186895;">of</span>
        <span style="color: #109ab8;">&#123;</span>ok<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">IoDevice</span><span style="color: #109ab8;">&#125;</span> <span style="color: #6bb810;">-&gt;</span>
            <span style="color: #45b3e6;">Dict</span> <span style="color: #014ea4;">=</span> <span style="color: #ff3c00;">process_each_line</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">IoDevice</span><span style="color: #6bb810;">,</span> <span style="color: #ff4e18;">dict</span>:<span style="color: #ff3c00;">new</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
            <span style="color: #ff3c00;">print_dict</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Dict</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">;</span>
    <span style="color: #186895;">end</span><span style="color: #6bb810;">.</span></pre></div></div>




Share and Enjoy:


	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F02%252Fword-frequency-redux-erlang-list-comprehension-regex-and-list-folding%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="twitter" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DWord%2520frequency%2520redux%2520-%2520Erlang%2520list%2520comprehension%252C%2520regex%2520and%2520list%2520folding%2520-%2520http%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F02%252Fword-frequency-redux-erlang-list-comprehension-regex-and-list-folding%252F';" title="Twitter"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F02%252Fword-frequency-redux-erlang-list-comprehension-regex-and-list-folding%252F%26amp%3Btitle%3DWord%2520frequency%2520redux%2520-%2520Erlang%2520list%2520comprehension%252C%2520regex%2520and%2520list%2520folding%26amp%3Bbodytext%3DSean%2520Cribbs%2520was%2520nice%2520enough%2520to%2520point%2520out%2520a%2520pair%2520of%2520changes%2520I%2520could%2520make%2520to%2520my%2520word%2520frequency%2520counter%2520from%2520last%2520time.%250D%250A%250D%250ABased%2520on%2520his%2520feedback%2520I%2520made%2520three%2520changes.%2520%2520First%2520-%2520the%2520regular%2520expression%2520code%2520has%2520changed%2520from%2520this%253A%250D%250A%250D%250A%250D%250Amatches%2528H%252C%257Bmatch%252CM%257D%2529%2520';" title="Digg"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="reddit" href="javascript:window.location='http%3A%2F%2Freddit.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F02%252Fword-frequency-redux-erlang-list-comprehension-regex-and-list-folding%252F%26amp%3Btitle%3DWord%2520frequency%2520redux%2520-%2520Erlang%2520list%2520comprehension%252C%2520regex%2520and%2520list%2520folding';" title="Reddit"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F02%252Fword-frequency-redux-erlang-list-comprehension-regex-and-list-folding%252F%26amp%3Btitle%3DWord%2520frequency%2520redux%2520-%2520Erlang%2520list%2520comprehension%252C%2520regex%2520and%2520list%2520folding%26amp%3Bnotes%3DSean%2520Cribbs%2520was%2520nice%2520enough%2520to%2520point%2520out%2520a%2520pair%2520of%2520changes%2520I%2520could%2520make%2520to%2520my%2520word%2520frequency%2520counter%2520from%2520last%2520time.%250D%250A%250D%250ABased%2520on%2520his%2520feedback%2520I%2520made%2520three%2520changes.%2520%2520First%2520-%2520the%2520regular%2520expression%2520code%2520has%2520changed%2520from%2520this%253A%250D%250A%250D%250A%250D%250Amatches%2528H%252C%257Bmatch%252CM%257D%2529%2520';" title="del.icio.us"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F02%252Fword-frequency-redux-erlang-list-comprehension-regex-and-list-folding%252F%26amp%3Bt%3DWord%2520frequency%2520redux%2520-%2520Erlang%2520list%2520comprehension%252C%2520regex%2520and%2520list%2520folding';" title="Facebook"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F02%252Fword-frequency-redux-erlang-list-comprehension-regex-and-list-folding%252F%26amp%3Btitle%3DWord%2520frequency%2520redux%2520-%2520Erlang%2520list%2520comprehension%252C%2520regex%2520and%2520list%2520folding%26amp%3Bannotation%3DSean%2520Cribbs%2520was%2520nice%2520enough%2520to%2520point%2520out%2520a%2520pair%2520of%2520changes%2520I%2520could%2520make%2520to%2520my%2520word%2520frequency%2520counter%2520from%2520last%2520time.%250D%250A%250D%250ABased%2520on%2520his%2520feedback%2520I%2520made%2520three%2520changes.%2520%2520First%2520-%2520the%2520regular%2520expression%2520code%2520has%2520changed%2520from%2520this%253A%250D%250A%250D%250A%250D%250Amatches%2528H%252C%257Bmatch%252CM%257D%2529%2520';" title="Google Bookmarks"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="stumbleupon" href="javascript:window.location='http%3A%2F%2Fwww.stumbleupon.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.roberthorvick.com%252F2009%252F07%252F02%252Fword-frequency-redux-erlang-list-comprehension-regex-and-list-folding%252F%26amp%3Btitle%3DWord%2520frequency%2520redux%2520-%2520Erlang%2520list%2520comprehension%252C%2520regex%2520and%2520list%2520folding';" title="StumbleUpon"><img src="http://www.roberthorvick.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.roberthorvick.com/2009/07/02/word-frequency-redux-erlang-list-comprehension-regex-and-list-folding/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
