A Twitter search client in 10 lines of code with F# and the JSON type provider

Twitter’s basic search API is pretty simple to use, and returns JSON back to you with tweets matching your search parameters.

JSON, eh?  “There’s an app a type provider for that.” I wonder if I could cook something up… Continue reading

Posted in F#, neat | 3 Comments

Tracking a new year’s resolution with F# and FSharpChart

This year, I have a goal of running 500 miles.  That’s not a crazy-ambitious goal, but between work, school, hobbies, friends, and (occasional) downtime, I think it’s plenty for me.  In contrast, the CEO of RunKeeper is planning to run 1,500 miles this year!  That’s an admirable goal, and I hope he succeeds (though I would prefer that he focus on releasing a Windows Phone app, instead.  Ah well…).

In order to stay motivated (and because it’s cool) I have decided to track my runs and chart my progress throughout the year.  Excel works just fine for this, but I want to try something a little different.  Why not use this as an opportunity to use FSharpChart? Continue reading

Posted in data, F#, neat | 2 Comments

Posting to Twitter from F#

Here’s some quick F# code which enables you to post updates (textual and/or with picture) to Twitter.  This isn’t full-featured or robust, but it gets the job done. Continue reading

Posted in F# | 2 Comments

Solution to a puzzle

Last time, I presented a mathematical puzzle.  Here, I will explain a solution.  If you have  come across this page first, but don’t want the solution spoiled, stop reading now!

Continue reading

Posted in neat, puzzle | Leave a comment

A puzzle

A starship is travelling at constant velocity through discrete, 1-dimensional space.  Its velocity is known to be some integral number of units per second.  You don’t know the ship’s position or the magnitude of its velocity ahead of time.

Your goal is to destroy the ship by hitting it with a photon torpedo.  You can detonate one torpedo per second, instantly, at any single point along the line of space.  Any particular point may be targeted as many or as few times as you please.  Your supply of torpedoes is unlimited.  There is no feedback from misses, but you do know when you hit the ship.  Assume time is discrete and aligned between you and the ship.

Devise an algorithm for firing the torpedoes that is guaranteed to hit the ship in some finite amount of time.  That is, if the ship’s location and velocity details at some point in time were to be  revealed, you could calculate the exact number of seconds it would take for your algorithm to find the ship. Continue reading

Posted in math, neat, puzzle | Leave a comment

A mini milestone

“I’ve got the byte on my side” reached 2,000 total views today!  Huzzah! Continue reading

Posted in blog, data | 1 Comment

The Bailey-Borwein-Plouffe algorithm in C# and F#

Earlier this year I wrote about calculating the first n digits of \pi using a Machin-style formula.  This type of formula is very efficient for generating all of the first n digits, but what if we really only want the nth digit by itself?  The most naive approach would be to calculate all of the digits, then simply pick the last one.  But is there is a faster way?  What does the code look like? Continue reading

Posted in C#, F#, math | 3 Comments