<?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>Three till Seven &#187; Techy</title>
	<atom:link href="http://www.3till7.net/category/techy/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.3till7.net</link>
	<description>Programming, espresso, and grumbling.</description>
	<lastBuildDate>Tue, 17 Aug 2010 02:29:12 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Dragon Age and credential grumblings</title>
		<link>http://www.3till7.net/2010/08/16/dragon-age-and-credential-grumblings/</link>
		<comments>http://www.3till7.net/2010/08/16/dragon-age-and-credential-grumblings/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 02:29:12 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Opinions]]></category>
		<category><![CDATA[Video games]]></category>
		<category><![CDATA[Dragon Age]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[video games]]></category>

		<guid isPermaLink="false">http://www.3till7.net/?p=4116</guid>
		<description><![CDATA[What have I been up to these past weeks?  Playing a lot of Dragon Age:  Origins and Awakening on my PS3, that&#8217;s what.  Well, that and working.  Neither of which leads to much discussion, so I haven&#8217;t written here and I&#8217;ve not emailed my parents as much, causing them to wonder [...]]]></description>
			<content:encoded><![CDATA[<p>What have I been up to these past weeks?  Playing a lot of Dragon Age:  Origins and Awakening on my PS3, that&#8217;s what.  Well, that and working.  Neither of which leads to much discussion, so I haven&#8217;t written here and I&#8217;ve not emailed my parents as much, causing them to wonder if I&#8217;d fallen off the planet.  I should send my mom a link to view my PS3 trophies online&mdash;<em>that</em> would show her I&#8217;m still alive.</p>
<div class="photo" style="width:230px"><a href="http://us.playstation.com/playstation/psn/visit/profiles/cheshire137"><img src="http://fp.profiles.us.playstation.com/playstation/psn/pid/cheshire137.png" width="230" height="155" border="0" /></a></div>
<p>I&#8217;ve run through Origins once as a mage and most of the way a second time as a rogue before I got tired of it and switched to Awakening.  I ended up finding a glitch letting me get a party member (Velanna) after I was supposed to, and getting into an area that was supposed to be locked down (the Silverite Mine), so I switched characters and ran through as a blood mage.  Bioware has announced they&#8217;re not fixing the Silverite Mine bug, which I don&#8217;t understand because there are plenty of other unpickable door locks, so why can&#8217;t they fix that one?  When I first got in there, none of the dialogue made sense because I hadn&#8217;t gotten Velanna in my party and she hadn&#8217;t told me her story yet.  I missed out on some cut scenes that I later saw when I ran through as a blood mage, too.</p>
<p>On the subject of glitches, I wish more sites would use OpenID for authentication.  I rather consider it a glitch that every time I want to log into, for example, my cell phone provider&#8217;s site, I have to use their Reset Password form because their password restrictions keep out my passwords of choice.  It&#8217;s ridiculous, too, because I like having, say, exclamation points in my passwords, but they disallow them, so my passwords are less secure.  I don&#8217;t want to use the same password everywhere, though I guess OpenID would pretty much be the same thing.  At least then I could focus on having one awesome password through a site like Google, that doesn&#8217;t have pointless password restrictions, and have that everywhere.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2010/08/16/dragon-age-and-credential-grumblings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows 7 64-bit ahoy!</title>
		<link>http://www.3till7.net/2010/05/19/windows-7-64-bit-ahoy/</link>
		<comments>http://www.3till7.net/2010/05/19/windows-7-64-bit-ahoy/#comments</comments>
		<pubDate>Thu, 20 May 2010 03:07:18 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Techy]]></category>
		<category><![CDATA[Sims]]></category>
		<category><![CDATA[video games]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.3till7.net/?p=4107</guid>
		<description><![CDATA[Look at this glorious screenshot taken from the system information of my desktop PC:

You see that?  All 4GB of my RAM are finally recognized by Windows 7!  No more &#8220;4GB (3GB usable)&#8221;!  I just now installed the 64-bit version because I&#8217;ve been having a slew of troubles with The Sims 3 in [...]]]></description>
			<content:encoded><![CDATA[<p>Look at this glorious screenshot taken from the system information of my desktop PC:</p>
<div class="photo" style="width:481px"><a href="/wp-content/uploads/2010/05/all_4gb_ram_recognized.png"><img src="/wp-content/uploads/2010/05/all_4gb_ram_recognized.png" alt="All 4GB of RAM recognized by Windows 7 64-bit" title="all_4gb_ram_recognized" /></a></div>
<p>You see that?  All 4GB of my RAM are finally recognized by Windows 7!  No more &#8220;4GB (3GB usable)&#8221;!  I just now installed the 64-bit version because I&#8217;ve been having a slew of troubles with The Sims 3 in Windows 7 32-bit, plus I wanted to go to 64-bit anyway, so I figured I&#8217;d take the leap.  Even with 64-bit, I had 3GB of usable RAM because some was marked as &#8220;hardware reserved.&#8221;  After a bit of Googling, I found I should check my BIOS settings for something like the following:  frame buffer size, video buffer size, or memory remapping.  I found the latter but there were two options:  h/w remapping and s/w remapping.  More Googling and forum-checking led me to enable s/w remapping and leave h/w remapping disabled.  Boot into Windows, and I see the above information&#8211;huzzah!</p>
<p>I still have EA Download Manager installing The Sims 3, so it&#8217;ll be a while yet before I know if this has fixed my oh-so-annoying crashes.  I would be playing along, doing fine, when suddenly my screen would go black and audio would be caught in a loop.  My monitor light would go orange and there would no longer be a signal to the monitor.  The only way to fix it was to hold in the reset button.  This seemed to most often happen when I was scrolling across the map.  It happened less frequently when I ran in windowed mode and killed all processes I thought I didn&#8217;t need.  It was getting to the point where I saved every 5 minutes because it was so frequent, and so annoying to lose all that unsaved progress.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2010/05/19/windows-7-64-bit-ahoy/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>TV update and Fat Princess tales</title>
		<link>http://www.3till7.net/2010/03/23/tv-update-and-fat-princess-tales/</link>
		<comments>http://www.3till7.net/2010/03/23/tv-update-and-fat-princess-tales/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 17:42:34 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Video games]]></category>
		<category><![CDATA[Fat Princess]]></category>
		<category><![CDATA[shopping]]></category>

		<guid isPermaLink="false">http://www.3till7.net/?p=4063</guid>
		<description><![CDATA[Well, I&#8217;ve upgraded my TV.  I purchased last night the ViewSonic VT2430 24-Inch 1080p LCD HDTV from Amazon and they emailed me this morning saying it shipped.  I&#8217;m surprised; I chose Free Super Saver Shipping and figured it wouldn&#8217;t ship for a couple of days and then take a while to get here, [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I&#8217;ve upgraded my TV.  I purchased last night the <a href="http://www.amazon.com/ViewSonic-VT2430-24-Inch-1080p-HDTV/dp/tech-data/B001KLEUOA/ref=de_a_smtd">ViewSonic VT2430 24-Inch 1080p LCD HDTV</a> from Amazon and they emailed me this morning saying it shipped.  I&#8217;m surprised; I chose Free Super Saver Shipping and figured it wouldn&#8217;t ship for a couple of days and then take a while to get here, but the delivery estimate is tomorrow.  I doubt I&#8217;ll be home when the UPS guy comes, I never am, but I&#8217;m used to picking up packages and for a TV I don&#8217;t really mind.  If I have to go pick it up, it&#8217;ll be a more worthwhile trip to me than if I have to pick up some small item that I wouldn&#8217;t have minded being left on my doorstep.</p>
<p>I planned on donating my 25&#8243; RCA TruFlat SDTV (a giant CRT thing) to Goodwill, but then Mark&#8217;s mom on Facebook inquired about it.  I checked <a href="http://www.salvationarmyusa.org/usn/www_usn_2.nsf/vw-dynamic-index/D477340FFA28755C8525743D0049D1EF?Opendocument">the Salvation Army&#8217;s valuation guide</a> and estimated my TV might be worth a $100 write-off, so I offered to sell it to her for that.  She&#8217;s not interested, and I don&#8217;t blame her since HDTV&#8217;s are getting so cheap.  Seriously, the new LCD HDTV I just bought was $258.99 and, about two years ago when I bought my current SDTV, I paid $258 for it!  Anyway, she informed me that Goodwill no longer accepts TV donations but apparently the Salvation Army does, which is good to know before I went tracking down a nearby Goodwill.</p>
<p>In other news, I&#8217;ve been playing Fat Princess on the PS3 like a fiend; I&#8217;m currently at the <a href="http://www.n4g.com/ps3/News-372058.aspx">rank of Ensign</a>.  Some of my best moments include:</p>
<dl class="padded">
<dt>Reign of terror</dt>
<dd>I was an upgraded Worker and had a Priest teammate following me around.  We got in a highly contested Outpost and he kept me healed while I chucked bombs down at all the enemies below.  We had a reign of terror that lasted for some time and garnered some serious points.  We eventually got killed but I went back later with another Priest, perhaps the same one, and did it again.  Anytime the Priest needed healing, he&#8217;d switch to the Dark Priest to suck life out of enemies, and I&#8217;d just jump out and run back into the Outpost to heal myself.</dd>
<dt>I just want to be a lumberjack</dt>
<dd>The game had just started and I was a Worker, chopping trees all by myself in Black Forest.  Suddenly, some enemy goes running past me carrying his princess.  I was like &#8220;oh shit!&#8221; and started chasing him down.  Of course the Worker wasn&#8217;t upgraded because we were so poor resource-wise, so I just hacked and slashed at him with my axe.  I had to chase him down into the water but eventually killed him.  I grabbed the princess and started running/swimming back to our castle.  My enemies were chasing me down, a few Warriors taking slashes at me, and I got down to the tiniest little heart but managed to make it to one of our Outposts.  I popped in the Outpost, still carrying the prisoner princess, and then came one of our Priests, healing me up fully.  I hopped out, carried the princess to our dungeon, and got 50 points.  I think it was an entirely different game, but the same thing happened again.  The lowly axe-carrying Worker saves the day!</dd>
<dt>Staving off defeat</dt>
<dd>I can&#8217;t remember the map but it was set up such that a little cliff was above each castle.  I ran to the cliff over my enemy&#8217;s castle while I was an upgraded Worker.  I just hung out up there, chucking bombs down into the castle below, right where their princess was sitting on the thrown.  When archers would shoot at me, I&#8217;d back up until they couldn&#8217;t reach me and still chuck bombs.  I know, I know, I&#8217;m a camper.  Anyway, my teammates would run up beside me and hop down to steal the princess, but the timer was going because they also had our princess in their dungeon.  Whenever the timer was almost up and my teammates weren&#8217;t around, I would hop down and grab their princess, running off with her as far as I could get.  Of course they always killed me before I made it out of the castle, but it was enough to decrease the timer until a flood of my teammates could make it and steal her more soundly.  We eventually lost the match but I staved off the end for a while!</dd>
<dt>Hallelujah, it&#8217;s raining royalty</dt>
<dd>I was doing my thing as either a Worker or a Mage, I can&#8217;t remember, when suddenly our princess came flying down in front of me from a fight that had happened on the cliff above me.  I was all &#8220;holy shit!&#8221; then grabbed the princess and started running for our castle.  I had to cross the whole map since I had been right next to the enemy castle.  I made it back to our castle and dumped her on our throne, getting I think 150 points for my trouble.</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2010/03/23/tv-update-and-fat-princess-tales/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>dying motherboard?</title>
		<link>http://www.3till7.net/2010/03/22/dying-motherboard/</link>
		<comments>http://www.3till7.net/2010/03/22/dying-motherboard/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 01:00:11 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Techy]]></category>
		<category><![CDATA[hardware]]></category>

		<guid isPermaLink="false">http://www.3till7.net/?p=4058</guid>
		<description><![CDATA[I think my PC&#8217;s motherboard is dying.  The other day while playing The Sims 3, my monitor suddenly displayed its &#8220;no signal&#8221; message and went to a black screen.  I checked the cord plugged into the monitor as well as the end plugged into the computer, and both were firmly in place.  [...]]]></description>
			<content:encoded><![CDATA[<p>I think my PC&#8217;s motherboard is dying.  The other day while playing The Sims 3, my monitor suddenly displayed its &#8220;no signal&#8221; message and went to a black screen.  I checked the cord plugged into the monitor as well as the end plugged into the computer, and both were firmly in place.  I shrugged it off as the result of upgrading to the latest Sims patch since I often see complaints in forums about new patches for the game causing problems.  I shut off my computer and left it alone.</p>
<p>Just now, I was going to boot into Windows to get the drivers for my Samsung Magnet so that I could transfer some files to it via its USB cable.  I couldn&#8217;t even boot because my BIOS gave me its &#8220;keyboard error or no keyboard present&#8221; message and wouldn&#8217;t get past the loading screen.  I tried plugging my new Microsoft keyboard into various USB ports to no avail.  I even got out my old but still-working Targus keyboard but didn&#8217;t have any luck.  I opened the computer case and jiggled all the connections I could think to jiggle, but I think perhaps the thing has just lived past its time.  Ugh, this means I need to go searching on Newegg for another motherboard, probably a new case, and make sure everything will work with my video card and memory.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2010/03/22/dying-motherboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>selling furniture and my dad on Twilight</title>
		<link>http://www.3till7.net/2010/03/16/selling-furniture-and-my-dad-on-twilight/</link>
		<comments>http://www.3till7.net/2010/03/16/selling-furniture-and-my-dad-on-twilight/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 18:00:46 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Video games]]></category>
		<category><![CDATA[Bayonetta]]></category>
		<category><![CDATA[Twilight is ridiculous]]></category>

		<guid isPermaLink="false">http://www.3till7.net/?p=4042</guid>
		<description><![CDATA[I had the sneaking suspicion that when I bought my PS3, it might make me long for a nicer TV.  That suspicion has turned into reality after bringing my PS3 home to let my brother try NCAA Football 2010 on it, and playing Bayonetta using his widescreen plasma TV.  The text in Antonio&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>I had the sneaking suspicion that when I bought my PS3, it might make me long for a nicer TV.  That suspicion has turned into reality after bringing my PS3 home to let my brother try NCAA Football 2010 on it, and playing Bayonetta using his widescreen plasma TV.  The text in Antonio&#8217;s Notebook, when read on my own 25&#8243; standard-definition TV, really messes with your eyes.  You get these vibrating lines around all the letters, I think because of the border on the text.  That goes away on my brother&#8217;s TV and I can read comfortably.  The rest of the game is much prettier, too, of course, and I can see more detail.  I can only imagine what getting an HD cable to go along with a nice widescreen HD TV would do for gameplay.</p>
<p>My problem though is that I need to get rid of my existing stuff before I go buying new stuff.  I&#8217;m trying to reduce the amount of crap I have in my apartment, and I&#8217;ve started by putting my loveseat up for sale on Craigslist.  I also cleared off one of my two bookshelves in my apartment and brought it home for my brother to use.  In the process, I picked out a bunch of books that I don&#8217;t figure I&#8217;ll want to read anytime soon, but that I otherwise don&#8217;t want to sell/donate, and I brought those home to store in my old bedroom.  I look forward to the day when I have a house from which I don&#8217;t plan to move for a long time, so that I can bring back all of my crap from my parents&#8217; house and either keep it, sell it, or donate it.  I would also like to sell my couch because it is a freaking heavy sleeper sofa that my old roommate picked out because she thought having a sleeper sofa would be a good thing.  I insist that it is not.  I for some reason bought the damn thing from her when we parted ways, though, and now I want it gone.  That would leave me with fancy camper chairs for seating, were I to sell the couch and the loveseat, but that would be oh so convenient when I move later this year.  I would end up buying a couch that is <em>not</em> a sleeper sofa for my new place.</p>
<p>Anywho, I&#8217;m still getting my ass kicked in Bayonetta at this harder difficulty setting, but I&#8217;m muddling through.  I&#8217;m discovering all kinds of new stuff that I missed the first time through, probably because I&#8217;m used to the game and recognize when something is out of ordinary.  I&#8217;m looking around a lot more, initially ignoring the obvious spot where they want me to go and poking around instead to find secrets.  I found the last piece of a record, allowing me to get a new weapon I didn&#8217;t have before:  the Kulshedra.  I&#8217;ve also discovered what those Broken Witch Hearts are good for (collect 4 to get a larger life bar) and have been actively seeking them out.  It&#8217;s funny that on Easy I didn&#8217;t have need of these things because it was easy enough I just blew through every fight.  I didn&#8217;t miss not finding the extra goodies because the game was easy enough without them.  Now I find myself in dire need of some of the green concoction components because I&#8217;m always using health lollipops and can&#8217;t make more.  I&#8217;m even running low on the yellow and red components used for the other lollies.</p>
<p>I was just reading about <a href="http://ps3.ign.com/articles/107/1075014p1.html">God of War III</a> and it sounds pretty fun.  I like the idea of battles played on top of huge creatures.  I enjoy that part of Bayonetta, and wish there were more battles with a crazy-large scale.</p>
<p>I find it interesting that before I bought a PS3 or became interested in owning one, I didn&#8217;t think there were many games for it that I would enjoy.  It&#8217;s probably because I didn&#8217;t even look at games that came out for the PS3 because I didn&#8217;t own one and didn&#8217;t plan on buying one.  Now that I do own one, though, and am looking at games for it, I find there are quite a few that I&#8217;m interested in playing.  It&#8217;s nice, because I kept replaying the same old games on my Wii:  Animal Crossing, Paper Mario, and Twilight Princess.</p>
<p>Ha!  My dad just said something to me about glittery vampires and I was all &#8220;what??  what do <em>you</em> know about glittery vampires?&#8221;.  He told me that they do get Showtime, and apparently he&#8217;s caught <em>Twilight</em> on there.  I told him how I was going to rent <em>New Moon</em> later this month and force Jon to watch it with me.  His response:  &#8220;You mean there&#8217;s more than one of these things??  I haven&#8217;t been able to sit through more than about thirty seconds of the first one!  It&#8217;s just stupid.  It&#8217;s unbelievably stupid!&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2010/03/16/selling-furniture-and-my-dad-on-twilight/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>beat Bayonetta</title>
		<link>http://www.3till7.net/2010/03/15/beat-bayonetta/</link>
		<comments>http://www.3till7.net/2010/03/15/beat-bayonetta/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 23:01:51 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Video games]]></category>
		<category><![CDATA[Bayonetta]]></category>

		<guid isPermaLink="false">http://www.3till7.net/?p=4040</guid>
		<description><![CDATA[I beat Bayonetta already, but perhaps I should note I was playing it on Easy.  I had first started the game in Normal mode, the hardest difficulty available, but after dying like crazy trying to get through one area, I switched it to Easy and just carried on like that.  I&#8217;m playing through [...]]]></description>
			<content:encoded><![CDATA[<p>I beat Bayonetta already, but perhaps I should note I was playing it on Easy.  I had first started the game in Normal mode, the hardest difficulty available, but after dying like crazy trying to get through one area, I switched it to Easy and just carried on like that.  I&#8217;m playing through it again on Normal and it&#8217;s <em>much</em> more difficult.  The game lets you keep all your stuff after you beat it, so I have all the same weapons and items as before.  I assumed I would still have the marionette Accessory from the first time through, so when I saw it was for sale at the Gates of Hell, I ignored it.  Turns out it took that Accessory away from me, either because I beat the game or I started playing again on Normal.  Now I can&#8217;t afford the darn thing but it was so helpful to have.  It allows you to bang away on the two main attack keys and it will generate random combos.  I pretty much do what Yahtzee from Zero Punctuation said in his review of Bayonetta:  flail around on the two attack buttons and hope for some awesome combo to come out.  Often times, it does.  *shrug*</p>
<p>One thing I wanted to point out (can&#8217;t remember if I&#8217;ve said as much before on here) is that I haven&#8217;t had any problem with the game&#8217;s load times.  I know I read in different reviews online of the game that everyone thought Bayonetta&#8217;s load times on the PS3 were ridiculous.  Now I haven&#8217;t tried the 360 version, but I did do one thing that I didn&#8217;t see other PS3 reviewers mention:  I chose the Install option before I ever started playing Bayonetta.  I saw it in the main menu, didn&#8217;t know what it would entail, but it sounded like a fine idea.  I&#8217;m guessing that doing that speeds up loading considerably by copying necessary stuff to the PS3 instead of always reading from disc.</p>
<p>I have Eternal Sonata ordered and it should arrive in a couple days.  Just in time, too, since I beat Bayonetta only yesterday.  I&#8217;ve been playing Pixeljunk Eden also, though I&#8217;ve only gotten 4/5 Spectra in Garden 1 and nothing in any other garden.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2010/03/15/beat-bayonetta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>got a PS3</title>
		<link>http://www.3till7.net/2010/03/04/got-a-ps3/</link>
		<comments>http://www.3till7.net/2010/03/04/got-a-ps3/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 02:08:42 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Video games]]></category>
		<category><![CDATA[Bayonetta]]></category>
		<category><![CDATA[shopping]]></category>
		<category><![CDATA[video games]]></category>

		<guid isPermaLink="false">http://www.3till7.net/?p=4032</guid>
		<description><![CDATA[Just a quick note to say Best Buy happened to get some 120GB PS3&#8217;s in today and I just happened to call at the right time, squeal &#8220;Omigod, can you hold one?!&#8221;, and buy one.  :)  I couldn&#8217;t find Eternal Sonata at either Best Buy or Gamestop, so I ended up with Bayonetta [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick note to say Best Buy happened to get some 120GB PS3&#8217;s in today and I just happened to call at the right time, squeal &#8220;Omigod, can you hold one?!&#8221;, and buy one.  :)  I couldn&#8217;t find Eternal Sonata at either Best Buy or Gamestop, so I ended up with Bayonetta instead.  After dying repeatedly in the prologue on Normal setting (the hardest setting there is, for some reason), I realized that using Triangle + Circle does combos a lot better, or something, and I&#8217;ve since progressed to Chapter 3 on Easy mode.  I&#8217;m really enjoying it.  Anyone who has a PSN account, my user name is cheshire137, if you want to friend me.  :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2010/03/04/got-a-ps3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PS3&#8217;s hard to find</title>
		<link>http://www.3till7.net/2010/02/27/ps3s-hard-to-find/</link>
		<comments>http://www.3till7.net/2010/02/27/ps3s-hard-to-find/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 19:55:02 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Video games]]></category>
		<category><![CDATA[shopping]]></category>
		<category><![CDATA[video games]]></category>

		<guid isPermaLink="false">http://www.3till7.net/?p=4003</guid>
		<description><![CDATA[I just wanted to buy a 120GB Playstation 3 but apparently everyone around here is sold out of them.  I figured the console has been out for a few years and the 120GB version came out in I think September, so I didn&#8217;t even consider that they would be hard to come by.  [...]]]></description>
			<content:encoded><![CDATA[<p>I just wanted to buy a 120GB Playstation 3 but apparently everyone around here is sold out of them.  I figured the console has been out for a few years and the 120GB version came out in I think September, so I didn&#8217;t even consider that they would be hard to come by.  The Best Buy rep I talked to said he didn&#8217;t know if Sony was intentionally trying to dry out the market or what; some online news I read said they were having manufacturing difficulties.</p>
<p>I found the 120GB version on Toys R Us&#8217;s web site for $299 and it said it was in stock.  Not trusting that to be accurate, since every other store I checked online was out of stock, and stores I called in person were sold out, I decided to call Toys R Us.  I fortunately got stuck with a phone menu that you talk into instead of the kind where you hit different buttons.  I say fortunately because the speak-aloud ones are easy to circumvent:  just wail and squeak and squeal different inhuman noises.  It frustrates the machine and causes it to say things like &#8220;I&#8217;m sorry, I didn&#8217;t get that&#8221; and eventually &#8220;Please hold while I connect you with a representative.&#8221;  Score!  I got a guy who checked for me and said it did indeed appear to be in their warehouse and that there shouldn&#8217;t be a delay in shipping.  We&#8217;ll see.  I went ahead and ordered it from their web site; $299 PS3, $13 shipping, and $18 in taxes later, my PS3 order was placed.</p>
<p>Games I&#8217;m looking forward to playing:</p>
<ul>
<li>Eternal Sonata</li>
<li>Heavy Rain</li>
<li>Katamari Damacy</li>
<li>Dragon Age</li>
<li>Heavenly Sword</li>
<li>Little Big Planet</li>
</ul>
<p>If you have any PS3 game suggestions, let me know.  :)  Also, has anyone else had trouble finding these things?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2010/02/27/ps3s-hard-to-find/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>convenient file searching with Ruby, grep, and file</title>
		<link>http://www.3till7.net/2010/02/23/convenient-file-searching-with-ruby-grep-and-file/</link>
		<comments>http://www.3till7.net/2010/02/23/convenient-file-searching-with-ruby-grep-and-file/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 18:26:30 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.3till7.net/?p=3990</guid>
		<description><![CDATA[For my Linux kernel class, I often know that some struct exists somewhere, or remember seeing a macro defined in some file and it might be useful, but I can't remember where I saw something.  I also end up trying to track down all the places a particular function is called, and don't want [...]]]></description>
			<content:encoded><![CDATA[<p>For my Linux kernel class, I often know that some <code>struct</code> exists somewhere, or remember seeing a macro defined in some file and it might be useful, but I can't remember where I saw something.  I also end up trying to track down all the places a particular function is called, and don't want grep to go digging through every... single... file in the entire kernel directory structure when I only care about .c files.  So, I dug up a lengthy combination of file and grep that limits grep's searching to particular files.  I'm lazy about remembering this and retyping it on different computers, too, though, so I wrote a quick Ruby script to do it for me:</p>
<div class="synthi_code" style="display:block;" id="styled_synthi_4c8126355e63a">
<h2 class="synthi_header"> Ruby</h2>
<div class="ruby" style="font-family: monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/ruby</span></p>
<p><span style="color:#9966CC; font-weight:bold;">unless</span> ARGV.<span style="color:#9900CC;">length</span> &gt;= <span style="color:#006666;">2</span><br />
&nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Usage:&nbsp; #$0 file_extension query&quot;</span><br />
&nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;<span style="color:#000099;">\t</span>Example: #$0 '*.h' 'struct list_head'&quot;</span><br />
&nbsp; <span style="color:#CC0066; font-weight:bold;">exit</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></p>
<p><span style="color:#9966CC; font-weight:bold;">unless</span> ARGV.<span style="color:#9900CC;">length</span> == <span style="color:#006666;">2</span><br />
&nbsp; extra_args = ARGV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">2</span>...<span style="color:#9900CC;">ARGV</span>.<span style="color:#9900CC;">length</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">join</span> ', '<br />
&nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Warning:&nbsp; extra arguments ignored: &quot;</span> &lt;&lt; extra_args<br />
<span style="color:#9966CC; font-weight:bold;">end</span></p>
<p>file_extension = ARGV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
query = ARGV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
command = <span style="color:#996600;">&quot;find . -type f -name '#{file_extension}' -print0 | xargs -0 grep --line-number --color -H -o '#{query}'&quot;</span><br />
<span style="color:#CC0066; font-weight:bold;">system</span> 'clear'<br />
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Searching #{file_extension} for <span style="color:#000099;">\&quot;</span>#{query}<span style="color:#000099;">\&quot;</span>...&quot;</span><br />
<span style="color:#CC0066; font-weight:bold;">system</span> command</div>
</div>
<p>Here's sample output on my Mac:</p>
<pre>Searching *.rb for "puts"...
./finder.rb:4:puts
./finder.rb:5:puts
./finder.rb:11:puts
./finder.rb:22:puts</pre>
<p>And here's some sample output from a Linux machine:</p>
<pre>Searching *.c for "struct task_struct"...
./fs/fcntl.c:414:struct task_struct
./fs/fcntl.c:423:struct task_struct
./fs/fcntl.c:462:struct task_struct
./fs/fcntl.c:481:struct task_struct
./fs/fcntl.c:490:struct task_struct</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2010/02/23/convenient-file-searching-with-ruby-grep-and-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>representing rational numbers in Smalltalk</title>
		<link>http://www.3till7.net/2010/02/07/representing-rational-numbers-in-smalltalk/</link>
		<comments>http://www.3till7.net/2010/02/07/representing-rational-numbers-in-smalltalk/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 22:09:20 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Smalltalk]]></category>

		<guid isPermaLink="false">http://www.3till7.net/?p=3957</guid>
		<description><![CDATA[For my graduate-level programming languages class, I wrote this class that represents a rational number in Smalltalk.  I figured I would share my source code with the interwebs for anyone else trying to learn the language.   I release the code under the GNU General Public License v3.
Note for students: my professor requested [...]]]></description>
			<content:encoded><![CDATA[<p>For my graduate-level programming languages class, I wrote this class that represents a rational number in Smalltalk.  I figured I would share my source code with the interwebs for anyone else trying to learn the language.   I release the code under the <a href="http://www.gnu.org/licenses/gpl-3.0.html">GNU General Public License v3</a>.</p>
<p><em>Note for students:</em> my professor requested I state that, should you be taking his programming languages class CS 655 at the University of Kentucky and you try to use this code, (1) you'll get in trouble for using someone else's work and (2) you have to include the GPL and my copyright notice, which would be a big hint that it's not entirely your work. ;)</p>
<div class="synthi_code" style="display:block;" id="styled_synthi_4c8126357cb75">
<h2 class="synthi_header"> Smalltalk</h2>
<div class="smalltalk" style="font-family: monospace;"><span style="color: #007f00; font-style: italic;">&quot; Copyright 2009 Sarah Vessels<br />
This program is free software: you can redistribute it and/or modify<br />
it under the terms of the GNU General Public License as published by<br />
the Free Software Foundation, either version 3 of the License, or<br />
(at your option) any later version.<br />
This program is distributed in the hope that it will be useful,<br />
but WITHOUT ANY WARRANTY; without even the implied warranty of<br />
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&nbsp; See the<br />
GNU General Public License for more details.<br />
You should have received a copy of the GNU General Public License<br />
along with this program.&nbsp; If not, see &lt;http://www.gnu.org/licenses/&gt;. &quot;</span><br />
<span style="color: #0000ff;">Object</span> subclass: <span style="color: #7f0000;">#Rational</span>.<br />
<span style="color: #0000ff;">Rational</span> instanceVariableNames: <span style="color: #7f0000;">'numerator denominator'</span>.<br />
<span style="color: #0000ff;">Rational</span> comment: <span style="color: #7f0000;">'I represent a fraction'</span>.</p>
<p><span style="color: #007f00; font-style: italic;">&quot; Thanks to http://en.wikipedia.org/wiki/Euclidean_algorithm &quot;</span><br />
<span style="color: #0000ff;">Rational</span> class extend <span style="">&#91;</span><br />
&nbsp; <span style="color: #00007f;">getGCD</span>: <span style="color: #00007f;">a</span> other: <span style="color: #00007f;">b</span> <span style="">&#91;</span><br />
&nbsp; &nbsp; |<span style="color: #0000ff;">A</span> <span style="color: #0000ff;">B</span>|<br />
&nbsp; &nbsp; <span style="color: #0000ff;">A</span> := <span style="color: #00007f;">a</span>.<br />
&nbsp; &nbsp; <span style="color: #0000ff;">B</span> := <span style="color: #00007f;">b</span>.<br />
&nbsp; &nbsp; <span style="">&#91;</span><span style="color: #0000ff;">B</span> ~= <span style="color: #00007f;"><span style="color: #7f0000;">0</span></span><span style="">&#93;</span> whileTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; |<span style="color: #00007f;">tmp</span>|<br />
&nbsp; &nbsp; &nbsp; <span style="color: #00007f;">tmp</span> := <span style="color: #0000ff;">B</span>.<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">B</span> := <span style="color: #0000ff;">A</span> \\ <span style="color: #0000ff;">B</span>.<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">A</span> := <span style="color: #00007f;">tmp</span>.<br />
&nbsp; &nbsp; <span style="">&#93;</span>.<br />
&nbsp; &nbsp; ^<span style="color: #0000ff;">A</span><br />
&nbsp; <span style="">&#93;</span><br />
<span style="">&#93;</span></p>
<p><span style="color: #007f00; font-style: italic;">&quot; Rational instance methods &quot;</span><br />
<span style="color: #0000ff;">Rational</span> extend <span style="">&#91;</span><br />
&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Given a numerator and a non-zero denominator, this will initialize the<br />
&nbsp; &nbsp; Rational. &quot;</span><br />
&nbsp; init: <span style="color: #00007f;">num</span> over: <span style="color: #00007f;">denom</span> <span style="">&#91;</span><br />
&nbsp; &nbsp; |<span style="color: #00007f;">gcd</span>|<br />
&nbsp; &nbsp; denom = <span style="color: #00007f;"><span style="color: #7f0000;">0</span></span> ifTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #7f007f;">self</span> error: <span style="color: #7f0000;">'Cannot have a 0 denominator'</span><br />
&nbsp; &nbsp; <span style="">&#93;</span>.</p>
<p>&nbsp; &nbsp; <span style="">&#40;</span><span style="color: #00007f;">num</span> isKindOf: <span style="color: #0000ff;">Integer</span><span style="">&#41;</span> ifFalse: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #7f007f;">self</span> error: <span style="color: #7f0000;">'Must have an Integer numerator'</span><br />
&nbsp; &nbsp; <span style="">&#93;</span>.</p>
<p>&nbsp; &nbsp; <span style="">&#40;</span><span style="color: #00007f;">denom</span> isKindOf: <span style="color: #0000ff;">Integer</span><span style="">&#41;</span> ifFalse: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #7f007f;">self</span> error: <span style="color: #7f0000;">'Must have a nonzero Integer denominator'</span><br />
&nbsp; &nbsp; <span style="">&#93;</span>.</p>
<p>&nbsp; &nbsp; <span style="color: #00007f;">gcd</span> := <span style="">&#40;</span><span style="color: #0000ff;">Rational</span> class new<span style="">&#41;</span> getGCD: <span style="color: #00007f;">num</span> other: <span style="color: #00007f;">denom</span>.<br />
&nbsp; &nbsp; <span style="color: #00007f;">numerator</span> := <span style="">&#40;</span><span style="color: #00007f;">num</span> / <span style="color: #00007f;">gcd</span><span style="">&#41;</span>.<br />
&nbsp; &nbsp; <span style="color: #00007f;">denominator</span> := <span style="">&#40;</span><span style="color: #00007f;">denom</span> / <span style="color: #00007f;">gcd</span><span style="">&#41;</span>.<br />
&nbsp; <span style="">&#93;</span></p>
<p>&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Given another Rational instance, this will return the Rational sum of this<br />
&nbsp; &nbsp; instance and the other instance. &quot;</span><br />
&nbsp; add: <span style="color: #00007f;">other</span> <span style="">&#91;</span><br />
&nbsp; &nbsp; |<span style="color: #00007f;">otherRat</span>|<br />
&nbsp; &nbsp; <span style="">&#40;</span><span style="color: #00007f;">other</span> isKindOf: <span style="color: #0000ff;">Integer</span><span style="">&#41;</span> ifTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #00007f;">otherRat</span> := <span style="">&#40;</span><span style="color: #0000ff;">Rational</span> new<span style="">&#41;</span> init: <span style="">&#40;</span><span style="color: #00007f;">other</span> * <span style="color: #00007f;">denominator</span><span style="">&#41;</span> over: <span style="color: #00007f;">denominator</span><br />
&nbsp; &nbsp; <span style="">&#93;</span> ifFalse: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; <span style="">&#40;</span><span style="color: #00007f;">other</span> isKindOf: <span style="color: #0000ff;">Rational</span><span style="">&#41;</span> ifTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f;">otherRat</span> := <span style="color: #00007f;">other</span><br />
&nbsp; &nbsp; &nbsp; <span style="">&#93;</span> ifFalse: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="">&#40;</span><span style="color: #7f007f;">self</span> error: <span style="color: #7f0000;">'Do not know how to add '</span>, <span style="">&#40;</span><span style="">&#40;</span><span style="color: #00007f;">other</span> class<span style="">&#41;</span> printString<span style="">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #7f0000;">' to Rational'</span><span style="">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="">&#93;</span><br />
&nbsp; &nbsp; <span style="">&#93;</span>.</p>
<p>&nbsp; &nbsp; <span style="color: #00007f;">denominator</span> = <span style="">&#40;</span><span style="color: #00007f;">otherRat</span> getDenominator<span style="">&#41;</span> ifTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; ^<span style="">&#40;</span><span style="color: #0000ff;">Rational</span> new<span style="">&#41;</span> init: <span style="">&#40;</span><span style="color: #00007f;">numerator</span> + <span style="">&#40;</span><span style="color: #00007f;">otherRat</span> getNumerator<span style="">&#41;</span><span style="">&#41;</span> over: <span style="color: #00007f;">denominator</span><br />
&nbsp; &nbsp; <span style="">&#93;</span> ifFalse: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; |<span style="color: #00007f;">lcd scaledNum1 scaledNum2</span>|<br />
&nbsp; &nbsp; &nbsp; <span style="color: #00007f;">lcd</span> := <span style="color: #7f007f;">self</span> getLCD: <span style="color: #00007f;">otherRat</span>.<br />
&nbsp; &nbsp; &nbsp; <span style="color: #00007f;">scaledNum1</span> := <span style="color: #7f007f;">self</span> scaleNumerator: <span style="color: #00007f;">lcd</span>.<br />
&nbsp; &nbsp; &nbsp; <span style="color: #00007f;">scaledNum2</span> := <span style="color: #00007f;">otherRat</span> scaleNumerator: <span style="color: #00007f;">lcd</span>.<br />
&nbsp; &nbsp; &nbsp; ^<span style="">&#40;</span><span style="color: #0000ff;">Rational</span> new<span style="">&#41;</span> init: <span style="">&#40;</span><span style="color: #00007f;">scaledNum1</span> + <span style="color: #00007f;">scaledNum2</span><span style="">&#41;</span> over: <span style="color: #00007f;">lcd</span><br />
&nbsp; &nbsp; <span style="">&#93;</span><br />
&nbsp; <span style="">&#93;</span></p>
<p>&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Will approximate the decimal value of the Rational. &quot;</span><br />
&nbsp; approximate <span style="">&#91;</span> ^<span style="">&#40;</span><span style="color: #00007f;">numerator</span> * <span style="color: #00007f;"><span style="color: #7f0000;">1</span></span>.<span style="color: #00007f;"><span style="color: #7f0000;">0</span></span><span style="">&#41;</span> / <span style="color: #00007f;">denominator</span> <span style="">&#93;</span></p>
<p>&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Given a Rational, compareTo compares this instance with the other Rational<br />
&nbsp; &nbsp; instance, returning -1, 0, or 1 depending on whether this instance is less<br />
&nbsp; &nbsp; than, equal to, or greater than the given instance, respectively. &quot;</span><br />
&nbsp; compareTo: <span style="color: #00007f;">other</span> <span style="">&#91;</span><br />
&nbsp; &nbsp; |<span style="color: #00007f;">otherDenom otherNum lcd</span>|<br />
&nbsp; &nbsp; <span style="">&#40;</span><span style="color: #7f007f;">self</span> equals: <span style="color: #00007f;">other</span><span style="">&#41;</span> ifTrue: <span style="">&#91;</span> ^<span style="color: #7f0000;">0</span> <span style="">&#93;</span>.</p>
<p>&nbsp; &nbsp; <span style="">&#40;</span><span style="color: #7f007f;">self</span> isPositive<span style="">&#41;</span> ifTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; <span style="">&#40;</span><span style="color: #00007f;">other</span> isNegative<span style="">&#41;</span> ifTrue: <span style="">&#91;</span> ^<span style="color: #7f0000;">1</span> <span style="">&#93;</span><br />
&nbsp; &nbsp; <span style="">&#93;</span>.</p>
<p>&nbsp; &nbsp; <span style="">&#40;</span><span style="color: #7f007f;">self</span> isNegative<span style="">&#41;</span> ifTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; <span style="">&#40;</span><span style="color: #00007f;">other</span> isPositive<span style="">&#41;</span> ifTrue: <span style="">&#91;</span> ^-<span style="color: #00007f;"><span style="color: #7f0000;">1</span></span> <span style="">&#93;</span><br />
&nbsp; &nbsp; <span style="">&#93;</span>.</p>
<p>&nbsp; &nbsp; <span style="color: #00007f;">otherDenom</span> := <span style="color: #00007f;">other</span> getDenominator.<br />
&nbsp; &nbsp; <span style="color: #00007f;">otherNum</span> := <span style="color: #00007f;">other</span> getNumerator.</p>
<p>&nbsp; &nbsp; <span style="color: #00007f;">denominator</span> = <span style="color: #00007f;">otherDenom</span> ifTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #00007f;">numerator</span> &amp;gt; otherNum ifTrue: <span style="">&#91;</span> ^<span style="color: #7f0000;">1</span> <span style="">&#93;</span><br />
&nbsp; &nbsp; &nbsp; ifFalse: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f;">numerator</span> = <span style="color: #00007f;">otherNum</span> ifTrue: <span style="">&#91;</span> ^<span style="color: #7f0000;">0</span> <span style="">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ifFalse: <span style="">&#91;</span> ^-<span style="color: #00007f;"><span style="color: #7f0000;">1</span></span> <span style="">&#93;</span><br />
&nbsp; &nbsp; &nbsp; <span style="">&#93;</span><br />
&nbsp; &nbsp; <span style="">&#93;</span>.</p>
<p>&nbsp; &nbsp; <span style="color: #00007f;">numerator</span> = <span style="color: #00007f;">otherNum</span> ifTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #00007f;">denominator</span> &amp;gt; otherDenom ifTrue: <span style="">&#91;</span> ^-<span style="color: #00007f;"><span style="color: #7f0000;">1</span></span> <span style="">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ifFalse: <span style="">&#91;</span> ^<span style="color: #7f0000;">1</span> <span style="">&#93;</span><br />
&nbsp; &nbsp; <span style="">&#93;</span>.</p>
<p>&nbsp; &nbsp; <span style="color: #00007f;">lcd</span> := <span style="color: #7f007f;">self</span> getLCD: <span style="color: #00007f;">other</span>.</p>
<p>&nbsp; &nbsp; <span style="">&#40;</span><span style="">&#40;</span><span style="color: #7f007f;">self</span> scaleNumerator: <span style="color: #00007f;">lcd</span><span style="">&#41;</span> &amp;gt; <span style="">&#40;</span><span style="color: #00007f;">other</span> scaleNumerator: <span style="color: #00007f;">lcd</span><span style="">&#41;</span><span style="">&#41;</span> ifTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; ^<span style="color: #7f0000;">1</span><br />
&nbsp; &nbsp; <span style="">&#93;</span> ifFalse: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; ^-<span style="color: #00007f;"><span style="color: #7f0000;">1</span></span><br />
&nbsp; &nbsp; <span style="">&#93;</span><br />
&nbsp; <span style="">&#93;</span></p>
<p>&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Given an Integer or Rational, this will divide this Rational by that<br />
&nbsp; &nbsp; value. &quot;</span><br />
&nbsp; divide: <span style="color: #00007f;">other</span> <span style="">&#91;</span><br />
&nbsp; &nbsp; |<span style="color: #00007f;">otherFrac reciprocal</span>|<br />
&nbsp; &nbsp; <span style="">&#40;</span><span style="color: #00007f;">other</span> isKindOf: <span style="color: #0000ff;">Integer</span><span style="">&#41;</span> ifTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #00007f;">otherFrac</span> := <span style="">&#40;</span><span style="color: #0000ff;">Rational</span> new<span style="">&#41;</span> init: <span style="color: #00007f;">other</span> over: <span style="color: #00007f;"><span style="color: #7f0000;">1</span></span>.<br />
&nbsp; &nbsp; <span style="">&#93;</span> ifFalse: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; <span style="">&#40;</span><span style="color: #00007f;">other</span> isKindOf: <span style="color: #0000ff;">Rational</span><span style="">&#41;</span> ifTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f;">otherFrac</span> := <span style="color: #00007f;">other</span><br />
&nbsp; &nbsp; &nbsp; <span style="">&#93;</span> ifFalse: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="">&#40;</span><span style="color: #7f007f;">self</span> error: <span style="color: #7f0000;">'Do not know how to divide a Ratioanl by '</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="">&#40;</span><span style="">&#40;</span><span style="color: #00007f;">other</span> class<span style="">&#41;</span> printString<span style="">&#41;</span><span style="">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="">&#93;</span><br />
&nbsp; &nbsp; <span style="">&#93;</span>.</p>
<p>&nbsp; &nbsp; <span style="color: #00007f;">reciprocal</span> := <span style="">&#40;</span><span style="">&#40;</span><span style="color: #0000ff;">Rational</span> new<span style="">&#41;</span> init: <span style="">&#40;</span><span style="color: #00007f;">otherFrac</span> getDenominator<span style="">&#41;</span><br />
&nbsp; &nbsp; &nbsp; over: <span style="">&#40;</span><span style="color: #00007f;">otherFrac</span> getNumerator<span style="">&#41;</span><span style="">&#41;</span>.<br />
&nbsp; &nbsp; ^<span style="color: #7f007f;">self</span> multiply: <span style="color: #00007f;">reciprocal</span><br />
&nbsp; <span style="">&#93;</span></p>
<p>&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Returns true if the given Rational equals this Rational, either as the same<br />
&nbsp; &nbsp; object or it represents the same fraction. &quot;</span><br />
&nbsp; equals: <span style="color: #00007f;">other</span> <span style="">&#91;</span><br />
&nbsp; &nbsp; <span style="color: #7f007f;">self</span> = <span style="color: #00007f;">other</span> ifTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; ^<span style="color: #7f007f;">true</span><br />
&nbsp; &nbsp; <span style="">&#93;</span> ifFalse: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #00007f;">numerator</span> = <span style="">&#40;</span><span style="color: #00007f;">other</span> getNumerator<span style="">&#41;</span> ifTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f;">denominator</span> = <span style="">&#40;</span><span style="color: #00007f;">other</span> getDenominator<span style="">&#41;</span> ifTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^<span style="color: #7f007f;">true</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="">&#93;</span> ifFalse: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^<span style="color: #7f007f;">false</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="">&#93;</span><br />
&nbsp; &nbsp; &nbsp; <span style="">&#93;</span> ifFalse: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ^<span style="color: #7f007f;">false</span><br />
&nbsp; &nbsp; &nbsp; <span style="">&#93;</span><br />
&nbsp; &nbsp; <span style="">&#93;</span><br />
&nbsp; <span style="">&#93;</span></p>
<p>&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Returns the denominator of the Rational. &quot;</span><br />
&nbsp; getDenominator <span style="">&#91;</span> ^denominator <span style="">&#93;</span></p>
<p>&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Given another instance of Rational, this will get the least common<br />
&nbsp; &nbsp; denominator (a.k.a. least common multiple) of the two denominators. &quot;</span><br />
&nbsp; getLCD: <span style="color: #00007f;">other</span> <span style="">&#91;</span><br />
&nbsp; &nbsp; |<span style="color: #00007f;">diff denominator2 product gcd</span>|<br />
&nbsp; &nbsp; <span style="color: #00007f;">denominator2</span> := <span style="color: #00007f;">other</span> getDenominator.<br />
&nbsp; &nbsp; <span style="color: #00007f;">diff</span> := <span style="">&#40;</span><span style="color: #00007f;">denominator</span> - <span style="color: #00007f;">denominator2</span><span style="">&#41;</span> abs.</p>
<p>&nbsp; &nbsp; <span style="color: #00007f;"><span style="color: #7f0000;">1</span></span> = <span style="color: #00007f;">diff</span> ifTrue: <span style="">&#91;</span> ^denominator * <span style="color: #00007f;">denominator2</span> <span style="">&#93;</span>.<br />
&nbsp; &nbsp; <span style="color: #00007f;"><span style="color: #7f0000;">0</span></span> = <span style="color: #00007f;">diff</span> ifTrue: <span style="">&#91;</span> ^denominator <span style="">&#93;</span>.</p>
<p>&nbsp; &nbsp; <span style="color: #00007f;">product</span> := <span style="">&#40;</span><span style="color: #00007f;">denominator</span> * <span style="color: #00007f;">denominator2</span><span style="">&#41;</span> abs.<br />
&nbsp; &nbsp; <span style="color: #00007f;">gcd</span> := <span style="">&#40;</span><span style="color: #0000ff;">Rational</span> class new<span style="">&#41;</span> getGCD: <span style="color: #00007f;">denominator</span> other: <span style="color: #00007f;">denominator2</span>.<br />
&nbsp; &nbsp; ^product / <span style="color: #00007f;">gcd</span><br />
&nbsp; <span style="">&#93;</span></p>
<p>&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Returns the numerator of the Rational. &quot;</span><br />
&nbsp; getNumerator <span style="">&#91;</span> ^numerator <span style="">&#93;</span></p>
<p>&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Returns the reciprocal of this Rational. &quot;</span><br />
&nbsp; getReciprocal <span style="">&#91;</span> ^<span style="">&#40;</span><span style="color: #0000ff;">Rational</span> new<span style="">&#41;</span> init: <span style="color: #00007f;">denominator</span> over: <span style="color: #00007f;">numerator</span> <span style="">&#93;</span></p>
<p>&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Returns true if this Rational is larger than the one given. &quot;</span><br />
&nbsp; greaterThan: <span style="color: #00007f;">other</span> <span style="">&#91;</span> ^<span style="">&#40;</span><span style="color: #7f007f;">self</span> compareTo: <span style="color: #00007f;">other</span><span style="">&#41;</span> = <span style="color: #00007f;"><span style="color: #7f0000;">1</span></span> <span style="">&#93;</span></p>
<p>&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Returns true if this Rational is larger than the one given, or has the<br />
&nbsp; &nbsp; same value. &quot;</span><br />
&nbsp; greaterThanOrEqualTo: <span style="color: #00007f;">other</span> <span style="">&#91;</span><br />
&nbsp; &nbsp; ^<span style="">&#40;</span><span style="color: #7f007f;">self</span> compareTo: <span style="color: #00007f;">other</span><span style="">&#41;</span> &amp;gt; -<span style="color: #00007f;"><span style="color: #7f0000;">1</span></span><br />
&nbsp; <span style="">&#93;</span></p>
<p>&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Will return true if this Rational is &amp;lt; 0. &quot;</span><br />
&nbsp; isNegative <span style="">&#91;</span><br />
&nbsp; &nbsp; ^<span style="color: #7f007f;">self</span> isPositive not<br />
&nbsp; <span style="">&#93;</span></p>
<p>&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Will return true if this Rational number is &amp;gt;= 0. &quot;</span><br />
&nbsp; isPositive <span style="">&#91;</span><br />
&nbsp; &nbsp; <span style="color: #00007f;">numerator</span> &amp;gt; <span style="color: #7f0000;">0</span> ifTrue: <span style="">&#91;</span> <span style="color: #00007f;">denominator</span> &amp;gt; <span style="color: #7f0000;">0</span> ifTrue: <span style="">&#91;</span> ^<span style="color: #7f007f;">true</span> <span style="">&#93;</span> <span style="">&#93;</span>.<br />
&nbsp; &nbsp; <span style="color: #00007f;">numerator</span> &amp;lt; <span style="color: #7f0000;">0</span> ifTrue: <span style="">&#91;</span> <span style="color: #00007f;">denominator</span> &amp;lt; <span style="color: #7f0000;">0</span> ifTrue: <span style="">&#91;</span> ^<span style="color: #7f007f;">true</span> <span style="">&#93;</span> <span style="">&#93;</span>.<br />
&nbsp; &nbsp; <span style="color: #00007f;">numerator</span> = <span style="color: #00007f;"><span style="color: #7f0000;">0</span></span> ifTrue: <span style="">&#91;</span> ^<span style="color: #7f007f;">true</span> <span style="">&#93;</span>.<br />
&nbsp; &nbsp; ^<span style="color: #7f007f;">false</span><br />
&nbsp; <span style="">&#93;</span></p>
<p>&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Returns true if this Rational is smaller than the one given. &quot;</span><br />
&nbsp; lessThan: <span style="color: #00007f;">other</span> <span style="">&#91;</span><br />
&nbsp; &nbsp; ^<span style="">&#40;</span><span style="color: #7f007f;">self</span> compareTo: <span style="color: #00007f;">other</span><span style="">&#41;</span> = -<span style="color: #00007f;"><span style="color: #7f0000;">1</span></span><br />
&nbsp; <span style="">&#93;</span></p>
<p>&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Returns true if this Rational is smaller than the one given, or has the<br />
&nbsp; &nbsp; same value. &quot;</span><br />
&nbsp; lessThanOrEqualTo: <span style="color: #00007f;">other</span> <span style="">&#91;</span><br />
&nbsp; &nbsp; ^<span style="">&#40;</span><span style="color: #7f007f;">self</span> compareTo: <span style="color: #00007f;">other</span><span style="">&#41;</span> &amp;lt; <span style="color: #7f0000;">1</span><br />
&nbsp; <span style="">&#93;</span></p>
<p>&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Given an Integer, this will scale the Rational by that amount.&nbsp; Given<br />
&nbsp; &nbsp; another Rational, this will return the product of this Rational and the one<br />
&nbsp; &nbsp; given. &quot;</span><br />
&nbsp; multiply: <span style="color: #00007f;">other</span> <span style="">&#91;</span><br />
&nbsp; &nbsp; |<span style="color: #00007f;">newNum newDenom</span>|<br />
&nbsp; &nbsp; <span style="">&#40;</span><span style="color: #00007f;">other</span> isKindOf: <span style="color: #0000ff;">Integer</span><span style="">&#41;</span> ifTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #00007f;">newNum</span> := <span style="color: #00007f;">numerator</span> * <span style="color: #00007f;">other</span>.<br />
&nbsp; &nbsp; &nbsp; <span style="color: #00007f;">newDenom</span> := <span style="color: #00007f;">denominator</span><br />
&nbsp; &nbsp; <span style="">&#93;</span> ifFalse: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; <span style="">&#40;</span><span style="color: #00007f;">other</span> isKindOf: <span style="color: #0000ff;">Rational</span><span style="">&#41;</span> ifTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f;">newNum</span> := <span style="color: #00007f;">numerator</span> * <span style="">&#40;</span><span style="color: #00007f;">other</span> getNumerator<span style="">&#41;</span>.<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f;">newDenom</span> := <span style="color: #00007f;">denominator</span> * <span style="">&#40;</span><span style="color: #00007f;">other</span> getDenominator<span style="">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="">&#93;</span> ifFalse: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7f007f;">self</span> error: <span style="color: #7f0000;">'Do not know how to multiply by '</span>, <span style="">&#40;</span><span style="">&#40;</span><span style="color: #00007f;">other</span> class<span style="">&#41;</span> printString<span style="">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="">&#93;</span><br />
&nbsp; &nbsp; <span style="">&#93;</span>.</p>
<p>&nbsp; &nbsp; ^<span style="">&#40;</span><span style="">&#40;</span><span style="color: #0000ff;">Rational</span> new<span style="">&#41;</span> init: <span style="color: #00007f;">newNum</span> over: <span style="color: #00007f;">newDenom</span><span style="">&#41;</span><br />
&nbsp; <span style="">&#93;</span></p>
<p>&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Returns a string representation of the Rational. &quot;</span><br />
&nbsp; printString <span style="">&#91;</span><br />
&nbsp; &nbsp; ^<span style="">&#40;</span><span style="color: #00007f;">numerator</span> printString<span style="">&#41;</span>, <span style="color: #7f0000;">'/'</span>, <span style="">&#40;</span><span style="color: #00007f;">denominator</span> printString<span style="">&#41;</span><br />
&nbsp; <span style="">&#93;</span></p>
<p>&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Given a least common denominator, this will return the numerator scaled up<br />
&nbsp; &nbsp; such that it pairs with the least common denominator. &quot;</span><br />
&nbsp; scaleNumerator: <span style="color: #00007f;">lcd</span> <span style="">&#91;</span><br />
&nbsp; &nbsp; <span style="color: #00007f;">denominator</span> = <span style="color: #00007f;">lcd</span> ifTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; ^numerator<br />
&nbsp; &nbsp; <span style="">&#93;</span> ifFalse: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; |<span style="color: #00007f;">factor</span>|<br />
&nbsp; &nbsp; &nbsp; <span style="color: #00007f;">factor</span> := <span style="color: #00007f;">lcd</span> / <span style="color: #00007f;">denominator</span>.<br />
&nbsp; &nbsp; &nbsp; ^numerator * <span style="color: #00007f;">factor</span><br />
&nbsp; &nbsp; <span style="">&#93;</span><br />
&nbsp; <span style="">&#93;</span></p>
<p>&nbsp; <span style="color: #007f00; font-style: italic;">&quot; Given another Rational, this will subtract the given Rational from this<br />
&nbsp; &nbsp; instance, returning the result as a Rational. &quot;</span><br />
&nbsp; subtract: <span style="color: #00007f;">other</span> <span style="">&#91;</span><br />
&nbsp; &nbsp; |<span style="color: #00007f;">negated negNum otherRat</span>|<br />
&nbsp; &nbsp; <span style="">&#40;</span><span style="color: #00007f;">other</span> isKindOf: <span style="color: #0000ff;">Integer</span><span style="">&#41;</span> ifTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #00007f;">otherRat</span> := <span style="">&#40;</span><span style="color: #0000ff;">Rational</span> new<span style="">&#41;</span> init: <span style="">&#40;</span><span style="color: #00007f;">denominator</span> * <span style="color: #00007f;">other</span><span style="">&#41;</span> over: <span style="color: #00007f;">denominator</span><br />
&nbsp; &nbsp; <span style="">&#93;</span> ifFalse: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; <span style="">&#40;</span><span style="color: #00007f;">other</span> isKindOf: <span style="color: #0000ff;">Rational</span><span style="">&#41;</span> ifTrue: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f;">otherRat</span> := <span style="color: #00007f;">other</span><br />
&nbsp; &nbsp; &nbsp; <span style="">&#93;</span> ifFalse: <span style="">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="">&#40;</span><span style="color: #7f007f;">self</span> error: <span style="color: #7f0000;">'Do not know how to subtract '</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="">&#40;</span><span style="">&#40;</span><span style="color: #00007f;">other</span> class<span style="">&#41;</span> printString<span style="">&#41;</span>, <span style="color: #7f0000;">' from Rational'</span><span style="">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="">&#93;</span><br />
&nbsp; &nbsp; <span style="">&#93;</span>.</p>
<p>&nbsp; &nbsp; <span style="color: #00007f;">negNum</span> := <span style="color: #00007f;"><span style="color: #7f0000;">0</span></span> - <span style="">&#40;</span><span style="color: #00007f;">otherRat</span> getNumerator<span style="">&#41;</span>.<br />
&nbsp; &nbsp; <span style="color: #00007f;">negated</span> := <span style="">&#40;</span><span style="color: #0000ff;">Rational</span> new<span style="">&#41;</span> init: <span style="color: #00007f;">negNum</span> over: <span style="">&#40;</span><span style="color: #00007f;">otherRat</span> getDenominator<span style="">&#41;</span>.<br />
&nbsp; &nbsp; ^<span style="color: #7f007f;">self</span> add: <span style="color: #00007f;">negated</span><br />
&nbsp; <span style="">&#93;</span><br />
<span style="">&#93;</span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2010/02/07/representing-rational-numbers-in-smalltalk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>the pain of Facebook application development</title>
		<link>http://www.3till7.net/2010/02/02/the-pain-of-facebook-application-development/</link>
		<comments>http://www.3till7.net/2010/02/02/the-pain-of-facebook-application-development/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 23:19:39 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[rants]]></category>

		<guid isPermaLink="false">http://www.3till7.net/?p=3867</guid>
		<description><![CDATA[For the past few days, I&#8217;ve been trying to create a Facebook application for interacting with Github.  I hoped to spend my time mainly on the Github portion, figuring out how to post wall posts on Facebook about recent Github activity, etc.  However, I&#8217;ve instead argued with the various Facebook APIs.  I [...]]]></description>
			<content:encoded><![CDATA[<p>For the past few days, I&#8217;ve been trying to create a Facebook application for interacting with Github.  I hoped to spend my time mainly on the Github portion, figuring out how to post wall posts on Facebook about recent Github activity, etc.  However, I&#8217;ve instead argued with the various Facebook APIs.  I started out using PHP with no framework but quickly switched to CakePHP after I realized things were going to get hairy.  CakePHP was okay for a while until I hit the roadblock of not being able to load any page but the index&#8230;  Every sub-page I tried to create produced 404 errors, which no one else seemed to have (or at least document), so I said &#8217;screw it&#8217; and switched to Rails.</p>
<p>I started out using the Facebooker API but got frustrated when I kept getting an error about not being able to convert nil to String.  I don&#8217;t even know now what was causing that.  I tried various ways of accessing Facebooker, via gem or plugin (though one of the developers says in <a href="http://forums.pragprog.com/forums/59/topics/692">this forum</a> that he hadn&#8217;t rebuilt the gem in a while, so use the plugin), with no luck.  So I switched to the older RFacebook and had troubles accessing the magical &#8220;fbsession&#8221; that every tutorial in the history of RFacebook tutorials glosses over like of <em>course</em> it&#8217;s available in your controller and if it&#8217;s not then you&#8217;re obviously retarded and should just write Visual Basic for the rest of your pitiful programming career.  Again, <em>screw that</em>.  Feeling hopeless at the lack of other Ruby APIs out there for Facebook, I went back to Facebooker and proceeded to get <a href="http://tools.ietf.org/html/rfc4918#section-11.2">422 Unprocessable Entity errors</a> (?!) whenever I would submit a POST request.  In my logs, I was seeing the following:</p>
<pre>ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
  facebooker (1.0.61) [v] lib/facebooker.rb:90:in `with_application'</pre>
<p>Lots of googling led to the aforelinked forum post wherein someone said to turn off forgery protection by commenting out the following line in <code>app/controllers/application_controller.rb</code></p>
<div class="synthi_code" style="display:block;" id="styled_synthi_4c81263597177">
<h2 class="synthi_header"> Ruby</h2>
<div class="ruby" style="font-family: monospace;">protect_from_forgery <span style="color:#008000; font-style:italic;"># See ActionController::RequestForgeryProtection for details </span></div>
</div>
<p>That doesn&#8217;t sound good, turning off forgery protection, but the forum poster said Facebook already provides it.  No idea if that&#8217;s true, but by damn, I just want to POST two string values to update the database!  Sheesh!  Anyway, so my posts work now and things are proceeding along as I would have expected them to three days ago.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2010/02/02/the-pain-of-facebook-application-development/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>two new programming projects</title>
		<link>http://www.3till7.net/2010/01/30/two-new-programming-projects/</link>
		<comments>http://www.3till7.net/2010/01/30/two-new-programming-projects/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 03:53:54 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Techy]]></category>
		<category><![CDATA[C-sharp]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.3till7.net/?p=3865</guid>
		<description><![CDATA[I&#8217;ve gone on a programming project binge today, coding first in C# on a project to add an enforceable Implements attribute to class members, then in PHP to write a Github application for Facebook.  I&#8217;m interested in co-developing the Facebook app, too, and have emailed a few of my programmer friends at UK to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve gone on a programming project binge today, coding first in C# on a project to add an enforceable <a href="http://github.com/moneypenny/ImplementsAttribute">Implements attribute</a> to class members, then in PHP to write a <a href="http://github.com/moneypenny/GithubFacebook">Github application for Facebook</a>.  I&#8217;m interested in co-developing the Facebook app, too, and have emailed a few of my programmer friends at UK to see if they&#8217;d like to participate in coding, testing, or some other part.  If you&#8217;re interested, let me know and I&#8217;ll get you access to the project on Github.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2010/01/30/two-new-programming-projects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TurboTax fail</title>
		<link>http://www.3till7.net/2009/12/28/turbotax-fail/</link>
		<comments>http://www.3till7.net/2009/12/28/turbotax-fail/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 23:05:43 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Techy]]></category>
		<category><![CDATA[rants]]></category>

		<guid isPermaLink="false">http://www.3till7.net/?p=3787</guid>
		<description><![CDATA[I received in the mail the other day a TurboTax install CD with an offer for free filing of federal and state tax returns.  Neat, I thought, and I was initially under the impression that they were giving me TurboTax for free.  Nope, turns out I still have to pay $60 for it, [...]]]></description>
			<content:encoded><![CDATA[<p>I received in the mail the other day a TurboTax install CD with an offer for free filing of federal and state tax returns.  Neat, I thought, and I was initially under the impression that they were giving me TurboTax for free.  Nope, turns out I still have to pay $60 for it, but whatever, there&#8217;s a $10 mail-in rebate and I&#8217;d pay at least $50 for it or a similar program at Walmart.  So I decided to install it just now and get everything set up for when I file my taxes in a couple/few months.  I&#8217;m under the impression that Mac support for the TurboTax install was tacked on as a last thought, because I couldn&#8217;t get past the fill-in-your-address screen to buy the program.</p>
<p>My first little problem came when I was going to have it create an account for me so I could easily buy TurboTax again in the future.  The labels for &#8220;Password&#8221;, &#8220;Password Again&#8221;, &#8220;Security Question&#8221;, etc. were offset from the form elements they went with.  Not a big deal since I could mostly figure out what went where, but it made me leery of trusting the company with my personal details.  If they can&#8217;t put some polish in their program to, uh, <em>make their forms legible</em>, which is kinda basic, I don&#8217;t exactly trust them to get security and privacy down pat.  So I skipped that step and was just going to do a one-time purchase for my 2009 tax return.  I fully filled out the form with my name, address, and phone number but when I hit the Continue button, it popped up an error:  make sure there are at least two characters in the Customer Billing Address2 field.  Uh, there <em>was</em> no Customer Billing Address2 field.  I had checked the &#8220;Billing address same as shipping address&#8221; checkbox, and there was only one set of address fields available.  Even in that set of address fields, there was only one field for &#8220;Address&#8221;, not a second one labeled &#8220;Address2&#8243;.  I couldn&#8217;t get it to go through, so I&#8217;m thinking I&#8217;ll go with H&amp;R Block&#8217;s tax program again this year, since it worked well for me last year.</p>
<p>On a side note, ever since I updated this blog to Wordpress 2.9, I&#8217;ve been having trouble Publishing posts.  I usually write up an entry in one shot and it auto-saves as I type, which is nice.  However, when I hit the Publish button, it redirects me to a page saying my attempt to edit the entry failed, would I like to try again.  I have to go to Posts &gt; Edit, open the saved draft, add in whatever tags I had tried to publish it with along with the title sometimes, and then Publish.  I hope this is fixed in an update.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2009/12/28/turbotax-fail/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>heap sort in ML</title>
		<link>http://www.3till7.net/2009/12/23/heap-sort-in-ml/</link>
		<comments>http://www.3till7.net/2009/12/23/heap-sort-in-ml/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 22:24:25 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ML]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.3till7.net/?p=3008</guid>
		<description><![CDATA[This past semester for my programming languages class, we had to implement heap sort in Standard ML.  This is my implementation, which I release under the GNU General Public License v3.  I split the code into two separate files:  shared.ml and heap_sort.ml, where shared.ml contains functions that might be of use with [...]]]></description>
			<content:encoded><![CDATA[<p>This past semester for my programming languages class, we had to implement <a href="http://en.wikipedia.org/wiki/Heap_sort">heap sort</a> in <a href="http://en.wikipedia.org/wiki/Standard_ML">Standard ML</a>.  This is my implementation, which I release under the <a href="http://www.gnu.org/licenses/gpl-3.0.html">GNU General Public License v3</a>.  I split the code into two separate files:  shared.ml and heap_sort.ml, where shared.ml contains functions that might be of use with other sorting algorithms and heap_sort.ml contains functions and code specific to heap sort.</p>
<p><em>Note for students:</em>  my professor requested I state that, should you be taking his programming languages class CS 655 at the University of Kentucky and you try to use this code, (1) you'll get in trouble for using someone else's work and (2) you have to include the GPL and my copyright notice, which would be a real big hint that it's not entirely your work.  ;)</p>
<h2>shared.ml</h2>
<div class="synthi_code" style="display:block;" id="styled_synthi_4c812635c4fec">
<h2 class="synthi_header"> OCaml</h2>
<div class="ocaml" style="font-family: monospace;"><span style="color: #5d478b; font-style: italic;">(* Copyright 2009 Sarah Vessels<br />
&nbsp; &nbsp; This program is free software: you can redistribute it and/or modify<br />
&nbsp; &nbsp; it under the terms of the GNU General Public License as published by<br />
&nbsp; &nbsp; the Free Software Foundation, either version 3 of the License, or<br />
&nbsp; &nbsp; (at your option) any later version.</p>
<p>&nbsp; &nbsp; This program is distributed in the hope that it will be useful,<br />
&nbsp; &nbsp; but WITHOUT ANY WARRANTY; without even the implied warranty of<br />
&nbsp; &nbsp; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&nbsp; See the<br />
&nbsp; &nbsp; GNU General Public License for more details.</p>
<p>&nbsp; &nbsp; You should have received a copy of the GNU General Public License<br />
&nbsp; &nbsp; along with this program.&nbsp; If not, see &lt;http://www.gnu.org/licenses/&gt;. *)</span></p>
<p><span style="color: #5d478b; font-style: italic;">(* Define a comparison function for integers that will return -1 if the first<br />
&nbsp;* element is smaller than the second, 0 if they are equal, and 1 if the first<br />
&nbsp;* element is larger than the second. *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> int_compare <span style="color: #6c6;">&#40;</span>a:int, b<span style="color: #6c6;">&#41;</span> = <span style="color: #06c; font-weight: bold;">if</span> a &lt; b <span style="color: #06c; font-weight: bold;">then</span> ~<span style="color: #c6c;">1</span> <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">if</span> a = b <span style="color: #06c; font-weight: bold;">then</span> <span style="color: #c6c;">0</span> <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #c6c;">1</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Comparison function for reals; see int_compare. *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> real_compare <span style="color: #6c6;">&#40;</span>a:real, b<span style="color: #6c6;">&#41;</span> = <span style="color: #06c; font-weight: bold;">if</span> a &lt; b <span style="color: #06c; font-weight: bold;">then</span> ~<span style="color: #c6c;">1</span> <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">if</span> a = b <span style="color: #06c; font-weight: bold;">then</span> <span style="color: #c6c;">0</span> <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #c6c;">1</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Comparison function for chars; see int_compare. *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> char_compare <span style="color: #6c6;">&#40;</span>a:char, b<span style="color: #6c6;">&#41;</span> = <span style="color: #06c; font-weight: bold;">if</span> a &lt; b <span style="color: #06c; font-weight: bold;">then</span> ~<span style="color: #c6c;">1</span> <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">if</span> a = b <span style="color: #06c; font-weight: bold;">then</span> <span style="color: #c6c;">0</span> <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #c6c;">1</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Comparison function for bools; see int_compare.&nbsp; Arbitrarily choosing true to<br />
&nbsp;* be less than false. *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> bool_compare <span style="color: #6c6;">&#40;</span>a:bool, b<span style="color: #6c6;">&#41;</span> = <span style="color: #06c; font-weight: bold;">if</span> a=<span style="color: #06c; font-weight: bold;">true</span> andalso b=<span style="color: #06c; font-weight: bold;">false</span> <span style="color: #06c; font-weight: bold;">then</span> ~<span style="color: #c6c;">1</span> <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">if</span> a = b <span style="color: #06c; font-weight: bold;">then</span> <span style="color: #c6c;">0</span> <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #c6c;">1</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Comparison function for strings; see int_compare. *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> str_compare <span style="color: #6c6;">&#40;</span>a:string, b<span style="color: #6c6;">&#41;</span> = <span style="color: #06c; font-weight: bold;">if</span> a &lt; b <span style="color: #06c; font-weight: bold;">then</span> ~<span style="color: #c6c;">1</span> <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">if</span> a = b <span style="color: #06c; font-weight: bold;">then</span> <span style="color: #c6c;">0</span> <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #c6c;">1</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Using the given comparison function, this returns true if a &lt;= b, false<br />
&nbsp;* otherwise. *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> leq <span style="color: #6c6;">&#40;</span>&lt;=&gt;, a, b<span style="color: #6c6;">&#41;</span> = <span style="color: #06c; font-weight: bold;">if</span> <span style="color: #6c6;">&#40;</span>&lt;=&gt; <span style="color: #6c6;">&#40;</span>a, b<span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#41;</span> &lt; <span style="color: #c6c;">1</span> <span style="color: #06c; font-weight: bold;">then</span> <span style="color: #06c; font-weight: bold;">true</span> <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">false</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Using the given comparison function, this returns true if a &gt;= b, false<br />
&nbsp;* otherwise. *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> geq <span style="color: #6c6;">&#40;</span>&lt;=&gt;, a, b<span style="color: #6c6;">&#41;</span> = <span style="color: #06c; font-weight: bold;">if</span> <span style="color: #6c6;">&#40;</span>&lt;=&gt; <span style="color: #6c6;">&#40;</span>a, b<span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#41;</span> &gt; ~<span style="color: #c6c;">1</span> <span style="color: #06c; font-weight: bold;">then</span> <span style="color: #06c; font-weight: bold;">true</span> <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">false</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Using the given comparison function, this returns true if a &lt; b, false<br />
&nbsp;* otherwise. *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> lt <span style="color: #6c6;">&#40;</span>&lt;=&gt;, a, b<span style="color: #6c6;">&#41;</span> = <span style="color: #06c; font-weight: bold;">if</span> <span style="color: #6c6;">&#40;</span>&lt;=&gt; <span style="color: #6c6;">&#40;</span>a, b<span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#41;</span> = ~<span style="color: #c6c;">1</span> <span style="color: #06c; font-weight: bold;">then</span> <span style="color: #06c; font-weight: bold;">true</span> <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">false</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Using the given comparison function, this returns true if a &gt; b, false<br />
&nbsp;* otherwise. *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> gt <span style="color: #6c6;">&#40;</span>&lt;=&gt;, a, b<span style="color: #6c6;">&#41;</span> = <span style="color: #06c; font-weight: bold;">if</span> <span style="color: #6c6;">&#40;</span>&lt;=&gt; <span style="color: #6c6;">&#40;</span>a, b<span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#41;</span> = <span style="color: #c6c;">1</span> <span style="color: #06c; font-weight: bold;">then</span> <span style="color: #06c; font-weight: bold;">true</span> <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">false</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Using the given comparison function, this returns true if a = b, false<br />
&nbsp;* otherwise. *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> eq <span style="color: #6c6;">&#40;</span>&lt;=&gt;, a, b<span style="color: #6c6;">&#41;</span> = <span style="color: #06c; font-weight: bold;">if</span> <span style="color: #6c6;">&#40;</span>&lt;=&gt; <span style="color: #6c6;">&#40;</span>a, b<span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#41;</span> = <span style="color: #c6c;">0</span> <span style="color: #06c; font-weight: bold;">then</span> <span style="color: #06c; font-weight: bold;">true</span> <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">false</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Returns a sub-list of the given list from indices i to j, inclusive. *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> sub_list <span style="color: #6c6;">&#40;</span>arr, i, j<span style="color: #6c6;">&#41;</span> =<br />
&nbsp; <span style="color: #06c; font-weight: bold;">let</span><br />
&nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* The last valid index in the given list *)</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">val</span> last_index = <span style="color: #6c6;">&#40;</span>length arr<span style="color: #6c6;">&#41;</span> - <span style="color: #c6c;">1</span><br />
&nbsp; <span style="color: #06c; font-weight: bold;">in</span><br />
&nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Ensure the given indices are valid in the given list. *)</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">if</span> i &gt;= <span style="color: #c6c;">0</span> andalso j &gt;= <span style="color: #c6c;">0</span> andalso i &lt;= last_index andalso j &lt;= last_index <span style="color: #06c; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">let</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* The first j+1 elements of the list *)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">val</span> first_els = <a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html"><span style="">List</span></a>.<span style="color: #060;">take</span> <span style="color: #6c6;">&#40;</span>arr, j<span style="color: #c6c;">+1</span><span style="color: #6c6;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">in</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">if</span> i &lt; j <span style="color: #06c; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Remove the first i elements of the first j+1 elements and return<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* what's left *)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html"><span style="">List</span></a>.<span style="color: #060;">drop</span> <span style="color: #6c6;">&#40;</span>first_els, i<span style="color: #6c6;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">if</span> i = j <span style="color: #06c; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Single-element list *)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6c6;">&#91;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html"><span style="">List</span></a>.<span style="color: #060;">nth</span> <span style="color: #6c6;">&#40;</span>arr, i<span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* i &gt; j, so call this method again with the smaller element passed as<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* the first index. *)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sub_list <span style="color: #6c6;">&#40;</span>arr, j, i<span style="color: #6c6;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">end</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Invalid indices given, return an empty list/nil. *)</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #6c6;">&#91;</span><span style="color: #6c6;">&#93;</span><br />
&nbsp; <span style="color: #06c; font-weight: bold;">end</span>;<br />
&nbsp; &nbsp; &nbsp; <br />
<span style="color: #5d478b; font-style: italic;">(* Given a list arr and indices i and j, this will swap the values in arr found<br />
&nbsp;* at the indices i and j *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> swap <span style="color: #6c6;">&#40;</span>arr, i, j<span style="color: #6c6;">&#41;</span> =<br />
&nbsp; <span style="color: #06c; font-weight: bold;">let</span><br />
&nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Get a list of the first elements in the original list, up to the ith<br />
&nbsp; &nbsp; &nbsp;* element *)</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">val</span> first_els = <a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html"><span style="">List</span></a>.<span style="color: #060;">take</span> <span style="color: #6c6;">&#40;</span>arr, i<span style="color: #6c6;">&#41;</span></p>
<p>&nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Get the ith element *)</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">val</span> i_el = <a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html"><span style="">List</span></a>.<span style="color: #060;">nth</span> <span style="color: #6c6;">&#40;</span>arr, i<span style="color: #6c6;">&#41;</span></p>
<p>&nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Get the jth element *)</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">val</span> j_el = <a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html"><span style="">List</span></a>.<span style="color: #060;">nth</span> <span style="color: #6c6;">&#40;</span>arr, j<span style="color: #6c6;">&#41;</span></p>
<p>&nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Get a list of the last elements in the original list, starting at the<br />
&nbsp; &nbsp; &nbsp;* (j+1)th element *)</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">val</span> last_els = <a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html"><span style="">List</span></a>.<span style="color: #060;">drop</span> <span style="color: #6c6;">&#40;</span>arr, j<span style="color: #c6c;">+1</span><span style="color: #6c6;">&#41;</span></p>
<p>&nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Get the last valid index in the given list *)</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">val</span> last_index = <span style="color: #6c6;">&#40;</span>length arr<span style="color: #6c6;">&#41;</span> - <span style="color: #c6c;">1</span><br />
&nbsp; <span style="color: #06c; font-weight: bold;">in</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">if</span> i &gt; last_index orelse i &lt; <span style="color: #c6c;">0</span> orelse j &gt; last_index orelse j &lt; <span style="color: #c6c;">0</span> <span style="color: #06c; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Error, so just return the original array *)</span><br />
&nbsp; &nbsp; &nbsp; arr<br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">if</span> i = j<span style="color: #c6c;">-1</span> <span style="color: #06c; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* No elements between i and j, so the swap is easy *)</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #6c6;">&#40;</span>first_els<span style="color: #6c6;">&#41;</span> @ <span style="color: #6c6;">&#91;</span>j_el<span style="color: #6c6;">&#93;</span> @ <span style="color: #6c6;">&#91;</span>i_el<span style="color: #6c6;">&#93;</span> @ <span style="color: #6c6;">&#40;</span>last_els<span style="color: #6c6;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">if</span> i &lt; j <span style="color: #06c; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">let</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Get a list of the elements strictly between indices i and j in<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* the original array *)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">val</span> between_els = sub_list <span style="color: #6c6;">&#40;</span>arr, i<span style="color: #c6c;">+1</span>, j<span style="color: #c6c;">-1</span><span style="color: #6c6;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">in</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6c6;">&#40;</span>first_els<span style="color: #6c6;">&#41;</span> @ <span style="color: #6c6;">&#91;</span>j_el<span style="color: #6c6;">&#93;</span> @ between_els @ <span style="color: #6c6;">&#91;</span>i_el<span style="color: #6c6;">&#93;</span> @ <span style="color: #6c6;">&#40;</span>last_els<span style="color: #6c6;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">end</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">if</span> i = j <span style="color: #06c; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Same indices given, no swap necessary *)</span><br />
&nbsp; &nbsp; &nbsp; arr<br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* i &gt; j, so call this method with the lower index first *)</span><br />
&nbsp; &nbsp; &nbsp; swap <span style="color: #6c6;">&#40;</span>arr, j, i<span style="color: #6c6;">&#41;</span><br />
&nbsp; <span style="color: #06c; font-weight: bold;">end</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Given a list, an index, and a value, this will return the same list with the<br />
&nbsp;* value at the given index set to be the given value. *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> set_value <span style="color: #6c6;">&#40;</span>arr, index, value<span style="color: #6c6;">&#41;</span> =<br />
&nbsp; <span style="color: #06c; font-weight: bold;">let</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">val</span> size = length arr<br />
&nbsp; <span style="color: #06c; font-weight: bold;">in</span><br />
&nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* If the given index is invalid, just return the original list,<br />
&nbsp; &nbsp; &nbsp;* unmodified. *)</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">if</span> index &lt; <span style="color: #c6c;">0</span> orelse index &gt;= size <span style="color: #06c; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; arr<br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Append the value to the end of the original list, then use swap to put<br />
&nbsp; &nbsp; &nbsp; &nbsp;* it at the desired index, then return only as many elements from the<br />
&nbsp; &nbsp; &nbsp; &nbsp;* new list as there were in the original list. *)</span><br />
&nbsp; &nbsp; &nbsp; <a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html"><span style="">List</span></a>.<span style="color: #060;">take</span> <span style="color: #6c6;">&#40;</span>swap <span style="color: #6c6;">&#40;</span>arr @ <span style="color: #6c6;">&#91;</span>value<span style="color: #6c6;">&#93;</span>, index, size<span style="color: #6c6;">&#41;</span>, size<span style="color: #6c6;">&#41;</span><br />
&nbsp; <span style="color: #06c; font-weight: bold;">end</span>;</div>
</div>
<h2>heap_sort.ml</h2>
<div class="synthi_code" style="display:block;" id="styled_synthi_4c812635d0bfb">
<h2 class="synthi_header"> OCaml</h2>
<div class="ocaml" style="font-family: monospace;"><span style="color: #5d478b; font-style: italic;">(* Copyright 2009 Sarah Vessels<br />
&nbsp; &nbsp; This program is free software: you can redistribute it and/or modify<br />
&nbsp; &nbsp; it under the terms of the GNU General Public License as published by<br />
&nbsp; &nbsp; the Free Software Foundation, either version 3 of the License, or<br />
&nbsp; &nbsp; (at your option) any later version.</p>
<p>&nbsp; &nbsp; This program is distributed in the hope that it will be useful,<br />
&nbsp; &nbsp; but WITHOUT ANY WARRANTY; without even the implied warranty of<br />
&nbsp; &nbsp; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&nbsp; See the<br />
&nbsp; &nbsp; GNU General Public License for more details.</p>
<p>&nbsp; &nbsp; You should have received a copy of the GNU General Public License<br />
&nbsp; &nbsp; along with this program.&nbsp; If not, see &lt;http://www.gnu.org/licenses/&gt;. *)</span><br />
use <span style="color: #3cb371;">&quot;shared.ml&quot;</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Given i, this will return the index of i's left child. *)</span><br />
<span style="color: #06c; font-weight: bold;">val</span> left_index = fn i =&gt; <span style="color: #c6c;">2</span>*i;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Given i, this will return the value at i's left child. *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> left_child <span style="color: #6c6;">&#40;</span>arr, i<span style="color: #6c6;">&#41;</span> = <a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html"><span style="">List</span></a>.<span style="color: #060;">nth</span> <span style="color: #6c6;">&#40;</span>arr, left_index i<span style="color: #6c6;">&#41;</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Given i, this will return the index of i's right child. *)</span><br />
<span style="color: #06c; font-weight: bold;">val</span> right_index = fn i =&gt; <span style="color: #6c6;">&#40;</span><span style="color: #c6c;">2</span>*i<span style="color: #6c6;">&#41;</span> + <span style="color: #c6c;">1</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Given i, this will return the value at i's right child. *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> right_child <span style="color: #6c6;">&#40;</span>arr, i<span style="color: #6c6;">&#41;</span> = <a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html"><span style="">List</span></a>.<span style="color: #060;">nth</span> <span style="color: #6c6;">&#40;</span>arr, right_index i<span style="color: #6c6;">&#41;</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Given a list arr, an index i, and the size of the heap contained in the<br />
&nbsp;* given list, this will returns the entire list, modified s.t. the heap rooted<br />
&nbsp;* at i is a max heap.&nbsp; This also requires a comparison function that works with<br />
&nbsp;* the type of elements found in the given list. *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> max_heapify_w_size <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, arr, i, heap_size<span style="color: #6c6;">&#41;</span> =<br />
&nbsp; <span style="color: #06c; font-weight: bold;">let</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">val</span> l = left_index i&nbsp; <span style="color: #5d478b; font-style: italic;">(* Index of i's left child *)</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">val</span> r = right_index i <span style="color: #5d478b; font-style: italic;">(* Index of i's right child *)</span></p>
<p>&nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Value at root i *)</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">val</span> value = <a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html"><span style="">List</span></a>.<span style="color: #060;">nth</span> <span style="color: #6c6;">&#40;</span>arr, i<span style="color: #6c6;">&#41;</span><br />
&nbsp; <span style="color: #06c; font-weight: bold;">in</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">if</span> <span style="color: #6c6;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; l &lt;= heap_size andalso<br />
&nbsp; &nbsp; &nbsp; gt <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, left_child <span style="color: #6c6;">&#40;</span>arr, i<span style="color: #6c6;">&#41;</span>, value<span style="color: #6c6;">&#41;</span> andalso<br />
&nbsp; &nbsp; &nbsp; <span style="color: #6c6;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; r &gt; heap_size orelse<br />
&nbsp; &nbsp; &nbsp; &nbsp; leq <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, right_child <span style="color: #6c6;">&#40;</span>arr, i<span style="color: #6c6;">&#41;</span>, left_child <span style="color: #6c6;">&#40;</span>arr, i<span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #6c6;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #6c6;">&#41;</span> <span style="color: #06c; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Largest is left child, so swap left child and root i, then max heapify<br />
&nbsp; &nbsp; &nbsp; &nbsp;* at the left child index. *)</span><br />
&nbsp; &nbsp; &nbsp; max_heapify_w_size <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, swap <span style="color: #6c6;">&#40;</span>arr, i, l<span style="color: #6c6;">&#41;</span>, l, heap_size<span style="color: #6c6;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">if</span> <span style="color: #6c6;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; r &lt;= heap_size andalso<br />
&nbsp; &nbsp; &nbsp; gt <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, right_child <span style="color: #6c6;">&#40;</span>arr, i<span style="color: #6c6;">&#41;</span>, value<span style="color: #6c6;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #6c6;">&#41;</span> <span style="color: #06c; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Largest is right child, so swap right child and root i, then max<br />
&nbsp; &nbsp; &nbsp; &nbsp;* heapify at the right child index. *)</span><br />
&nbsp; &nbsp; &nbsp; max_heapify_w_size <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, swap <span style="color: #6c6;">&#40;</span>arr, i, r<span style="color: #6c6;">&#41;</span>, r, heap_size<span style="color: #6c6;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Largest is root i, no change necessary, just return the list<br />
&nbsp; &nbsp; &nbsp; &nbsp;* unchanged. *)</span><br />
&nbsp; &nbsp; &nbsp; arr<br />
&nbsp; <span style="color: #06c; font-weight: bold;">end</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Convenience function for max heapifying a heap in the given list rooted at<br />
&nbsp;* the given i with a fixed heap size (namely, one less than the length of the<br />
&nbsp;* given list).&nbsp; Requires a comparison function for comparing elements in the<br />
&nbsp;* given list. *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> max_heapify <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, arr, i<span style="color: #6c6;">&#41;</span> =<br />
&nbsp; max_heapify_w_size <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, arr, i, <span style="color: #6c6;">&#40;</span>length arr<span style="color: #6c6;">&#41;</span> - <span style="color: #c6c;">1</span><span style="color: #6c6;">&#41;</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Recursive method for turning an entire given list into a max heap.&nbsp; Requires<br />
&nbsp;* the initial root for max_heapify be given as a parameter.&nbsp; Requires a<br />
&nbsp;* comparison function for comparing elements in the given list. *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> build_max_heap_rec <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, arr, <span style="color: #c6c;">0</span><span style="color: #6c6;">&#41;</span> = max_heapify <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, arr, <span style="color: #c6c;">0</span><span style="color: #6c6;">&#41;</span><br />
&nbsp; | build_max_heap_rec <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, arr, i<span style="color: #6c6;">&#41;</span> =<br />
&nbsp; &nbsp; &nbsp; build_max_heap_rec <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, max_heapify <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, arr, i<span style="color: #6c6;">&#41;</span>, i<span style="color: #c6c;">-1</span><span style="color: #6c6;">&#41;</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Convenience function for turning an entire given list into a max heap.&nbsp; Makes<br />
&nbsp;* use of the build_max_heap_rec function by passing in an initial root to<br />
&nbsp;* max_heapify.&nbsp; Requires a comparison function to compare elements in the given<br />
&nbsp;* list. *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> build_max_heap <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, arr<span style="color: #6c6;">&#41;</span> =<br />
&nbsp; <span style="color: #06c; font-weight: bold;">let</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">val</span> heap_size = <span style="color: #6c6;">&#40;</span>length arr<span style="color: #6c6;">&#41;</span> - <span style="color: #c6c;">1</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">val</span> initial_i = heap_size div <span style="color: #c6c;">2</span><br />
&nbsp; <span style="color: #06c; font-weight: bold;">in</span><br />
&nbsp; &nbsp; build_max_heap_rec <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, arr, initial_i<span style="color: #6c6;">&#41;</span><br />
&nbsp; <span style="color: #06c; font-weight: bold;">end</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* A recursive heap_sort implementation taking a list, an initial index, and a<br />
&nbsp;* heap size for the given list.&nbsp; Requires a comparison function to compare<br />
&nbsp;* elements in the given list. *)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> heap_sort_rec <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, arr, <span style="color: #c6c;">1</span>, heap_size<span style="color: #6c6;">&#41;</span> =<br />
&nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Max heapify the list at root 0 after swapping the values at indices 0 and<br />
&nbsp; &nbsp; &nbsp;* 1 in the given list. *)</span><br />
&nbsp; &nbsp; max_heapify_w_size <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, swap <span style="color: #6c6;">&#40;</span>arr, <span style="color: #c6c;">0</span>, <span style="color: #c6c;">1</span><span style="color: #6c6;">&#41;</span>, <span style="color: #c6c;">0</span>, heap_size<span style="color: #c6c;">-1</span><span style="color: #6c6;">&#41;</span><br />
&nbsp; | heap_sort_rec <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, arr, i, heap_size<span style="color: #6c6;">&#41;</span> =<br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">let</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Decrement the heap size we're looking at by 1 each time *)</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">val</span> dec_heap_size = heap_size<span style="color: #c6c;">-1</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">in</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #5d478b; font-style: italic;">(* Swap the values at indices 0 and i, then recursively heap_sort the<br />
&nbsp; &nbsp; &nbsp; &nbsp;* modified list by looking at the next value for i and looking at a<br />
&nbsp; &nbsp; &nbsp; &nbsp;* smaller heap *)</span><br />
&nbsp; &nbsp; &nbsp; heap_sort_rec <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, max_heapify_w_size <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, swap <span style="color: #6c6;">&#40;</span>arr, <span style="color: #c6c;">0</span>, i<span style="color: #6c6;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c6c;">0</span>, dec_heap_size<span style="color: #6c6;">&#41;</span>, i<span style="color: #c6c;">-1</span>, dec_heap_size<span style="color: #6c6;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">end</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Convenience function for sorting a given list with heap_sort.&nbsp; Makes use of<br />
&nbsp;* heap_sort_rec by passing in an initial index and initial heap size.<br />
&nbsp;* Initially converts the given list into a max heap, which is necessary for<br />
&nbsp;* heap_sort.&nbsp; Requires a comparison function for comparing the elements in the<br />
&nbsp;* given list.<br />
&nbsp;*)</span><br />
<span style="color: #06c; font-weight: bold;">fun</span> heap_sort <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, arr<span style="color: #6c6;">&#41;</span> = <br />
&nbsp; <span style="color: #06c; font-weight: bold;">let</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">val</span> heap_size = <span style="color: #6c6;">&#40;</span>length arr<span style="color: #6c6;">&#41;</span> - <span style="color: #c6c;">1</span><br />
&nbsp; &nbsp; <span style="color: #06c; font-weight: bold;">val</span> max_heap = build_max_heap <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, arr<span style="color: #6c6;">&#41;</span><br />
&nbsp; <span style="color: #06c; font-weight: bold;">in</span><br />
&nbsp; &nbsp; heap_sort_rec <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALcompare"><span style="">compare</span></a>, max_heap, heap_size, heap_size<span style="color: #6c6;">&#41;</span><br />
&nbsp; <span style="color: #06c; font-weight: bold;">end</span>;</p>
<p><span style="color: #5d478b; font-style: italic;">(* Example unsorted lists and the results of heap-sorting them.&nbsp; I don't print<br />
&nbsp;* these out because mosml shows the results when you run this file. *)</span><br />
print <span style="color: #3cb371;">&quot;Sorting integers:\n&quot;</span>;<br />
<span style="color: #06c; font-weight: bold;">val</span> unsorted_list = <span style="color: #6c6;">&#91;</span><span style="color: #c6c;">16</span>, <span style="color: #c6c;">4</span>, <span style="color: #c6c;">10</span>, <span style="color: #c6c;">14</span>, <span style="color: #c6c;">7</span>, <span style="color: #c6c;">9</span>, <span style="color: #c6c;">3</span>, <span style="color: #c6c;">2</span>, <span style="color: #c6c;">8</span>, <span style="color: #c6c;">1</span><span style="color: #6c6;">&#93;</span>;<br />
<span style="color: #06c; font-weight: bold;">val</span> sorted = heap_sort <span style="color: #6c6;">&#40;</span>int_compare, unsorted_list<span style="color: #6c6;">&#41;</span>;</p>
<p><span style="color: #06c; font-weight: bold;">val</span> unsorted_list = <span style="color: #6c6;">&#91;</span><span style="color: #c6c;">5</span>, <span style="color: #c6c;">4</span>, <span style="color: #c6c;">3</span>, <span style="color: #c6c;">2</span>, <span style="color: #c6c;">1</span>, <span style="color: #c6c;">0</span>, ~<span style="color: #c6c;">1</span>, ~<span style="color: #c6c;">2</span>, ~<span style="color: #c6c;">3</span>, ~<span style="color: #c6c;">4</span>, ~<span style="color: #c6c;">5</span><span style="color: #6c6;">&#93;</span>;<br />
<span style="color: #06c; font-weight: bold;">val</span> sorted = heap_sort <span style="color: #6c6;">&#40;</span>int_compare, unsorted_list<span style="color: #6c6;">&#41;</span>;</p>
<p>print <span style="color: #3cb371;">&quot;Sorting strings:\n&quot;</span>;<br />
<span style="color: #06c; font-weight: bold;">val</span> unsorted_list = <span style="color: #6c6;">&#91;</span><span style="color: #3cb371;">&quot;my&quot;</span>, <span style="color: #3cb371;">&quot;mother&quot;</span>, <span style="color: #3cb371;">&quot;told&quot;</span>, <span style="color: #3cb371;">&quot;me&quot;</span>, <span style="color: #3cb371;">&quot;to&quot;</span>, <span style="color: #3cb371;">&quot;pick&quot;</span>, <span style="color: #3cb371;">&quot;the&quot;</span>, <span style="color: #3cb371;">&quot;very&quot;</span><span style="color: #6c6;">&#93;</span><br />
<span style="color: #06c; font-weight: bold;">val</span> sorted = heap_sort <span style="color: #6c6;">&#40;</span>str_compare, unsorted_list<span style="color: #6c6;">&#41;</span>;</p>
<p><span style="color: #06c; font-weight: bold;">val</span> unsorted_list = <span style="color: #6c6;">&#91;</span><span style="color: #3cb371;">&quot;best&quot;</span>, <span style="color: #3cb371;">&quot;one&quot;</span>, <span style="color: #3cb371;">&quot;and&quot;</span>, <span style="color: #3cb371;">&quot;you&quot;</span>, <span style="color: #3cb371;">&quot;are&quot;</span>, <span style="color: #3cb371;">&quot;not&quot;</span>, <span style="color: #3cb371;">&quot;not&quot;</span>, <span style="color: #3cb371;">&quot;it&quot;</span><span style="color: #6c6;">&#93;</span><br />
<span style="color: #06c; font-weight: bold;">val</span> sorted = heap_sort <span style="color: #6c6;">&#40;</span>str_compare, unsorted_list<span style="color: #6c6;">&#41;</span>;</p>
<p>print <span style="color: #3cb371;">&quot;Sorting Booleans:\n&quot;</span>;<br />
<span style="color: #06c; font-weight: bold;">val</span> unsorted_list = <span style="color: #6c6;">&#91;</span><span style="color: #06c; font-weight: bold;">false</span>, <span style="color: #06c; font-weight: bold;">true</span><span style="color: #6c6;">&#93;</span>;<br />
<span style="color: #06c; font-weight: bold;">val</span> sorted = heap_sort <span style="color: #6c6;">&#40;</span>bool_compare, unsorted_list<span style="color: #6c6;">&#41;</span>;</p>
<p>print <span style="color: #3cb371;">&quot;Sorting characters:\n&quot;</span>;<br />
<span style="color: #06c; font-weight: bold;">val</span> unsorted_list = <span style="color: #6c6;">&#91;</span>#<span style="color: #3cb371;">&quot;z&quot;</span>, #<span style="color: #3cb371;">&quot;k&quot;</span>, #<span style="color: #3cb371;">&quot;b&quot;</span>, #<span style="color: #3cb371;">&quot;c&quot;</span>, #<span style="color: #3cb371;">&quot;f&quot;</span><span style="color: #6c6;">&#93;</span>;<br />
<span style="color: #06c; font-weight: bold;">val</span> sorted = heap_sort <span style="color: #6c6;">&#40;</span>char_compare, unsorted_list<span style="color: #6c6;">&#41;</span>;</p>
<p>print <span style="color: #3cb371;">&quot;Sorting reals:\n&quot;</span>;<br />
<span style="color: #06c; font-weight: bold;">val</span> unsorted_list = <span style="color: #6c6;">&#91;</span><span style="color: #c6c;">1.3</span>, ~<span style="color: #c6c;">0.225</span>, <span style="color: #c6c;">3.1415</span>, <span style="color: #c6c;">87.5</span><span style="color: #6c6;">&#93;</span>;<br />
<span style="color: #06c; font-weight: bold;">val</span> sorted = heap_sort <span style="color: #6c6;">&#40;</span>real_compare, unsorted_list<span style="color: #6c6;">&#41;</span>;</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2009/12/23/heap-sort-in-ml/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>inflexible Adobe</title>
		<link>http://www.3till7.net/2009/12/08/inflexible-adobe/</link>
		<comments>http://www.3till7.net/2009/12/08/inflexible-adobe/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 20:49:47 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Techy]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[shopping]]></category>

		<guid isPermaLink="false">http://www.3till7.net/?p=3740</guid>
		<description><![CDATA[Wow, Adobe doesn&#8217;t make things convenient for you.  I just called about their $199 offer for Photoshop CS4 for students, hoping that I could use it on my Mac or in Windows and perhaps be restricted to using only one at a time, but no.  I can download it for Mac or Windows, [...]]]></description>
			<content:encoded><![CDATA[<p>Wow, Adobe doesn&#8217;t make things convenient for you.  I just called about their $199 offer for Photoshop CS4 for students, hoping that I could use it on my Mac or in Windows and perhaps be restricted to using only one at a time, but no.  I can download it for Mac <em>or</em> Windows, but I can&#8217;t have both.  I don&#8217;t even have the option of buying a second license (not that I would want to do that, because $199 is a lot to begin with) because with the student edition, you&#8217;re only allowed one license.  Honestly, what do they care which operating system I use it on?  It seems like they could do some kind of check to ensure the registration key is not currently active on some other computer at the time, allowing me to work on either my Mac laptop or my Windows desktop PC.  I paid once for <a href="http://www.artrage.com/">ArtRage</a> and now have the option to install it in Windows or Mac using one license.</p>
<p>Another question I had was if I had to pay the $199 all at once or if they offered some kind of installment plan.  I just figured a big company like Adobe would offer such conveniences, considering that Apple and other companies do.  Hell, I can buy an iMac for $28/month, and its total cost is <em>way</em> more than the student Photoshop at $199.  *rolls eyes*  Way to be inflexible and lose a sale, Adobe.  Guess I&#8217;ll continue with <a href="http://www.gimp.org/">GIMP</a> and ArtRage.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2009/12/08/inflexible-adobe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
