Wednesday, August 12th, 2009
Updated: Note that this is available as a clojars module. Clojure code density seems to be pretty good. There are a fair number of convenient shortforms in the language; for example, associative datatypes all act as a function — so given a hash map you can reference it with (my-hashmap :key). The base language itself [...]
Posted in clojure, coding | 13 Comments »
Monday, April 13th, 2009
Let’s say that you really, really want some notion of objected oriented programming. So let’s make a class that represents a name, and some simple method calls on it: [code lang="haskell"] data S = S { name :: String } deriving (Show) firstname s = (words (name s))!!0 lastname s = (words (name s))!!1 [/code] [...]
Posted in coding, haskell | No Comments »
Friday, April 10th, 2009
A small snippet of code that demonstrates calling into a WordPress XML-RPC server with Haskell and HaxR. [code lang="haskell"] import qualified Data.Map as Map import Data.Maybe import Network.XmlRpc.Client import Network.XmlRpc.Internals server = "http://yourserver.wordpress.com/xmlrpc.php" -- extract multiple posts from the XML response extract :: Value -> [Map String Value] extract xmlresp = let ValueArray rs = [...]
Posted in coding, haskell | No Comments »
Sunday, March 29th, 2009
Ran into another interesting performance problem while converting a small test program over to Haskell. Let’s say that you want to walk through every line of a text file, collate character frequencies, and return anything that maps to a particular frequency. For purposes of explanation we’ll do something really silly like look for lines with [...]
Posted in coding, haskell | 4 Comments »
Saturday, March 28th, 2009
I was trying to track down some issues with some text processing programs that I was writing in Haskell, and ran into an interesting problem. I made one small change and my program ended up being 5 times slower, and I had to backtrack to try and find out what it was. So, given a [...]
Posted in coding, haskell | 1 Comment »
Thursday, March 19th, 2009
For comparison purposes, I was rewriting the silly little e-mail digest program in Haskell, using Python libraries for the IMAP interface (it’s available on Github). It’s hard to beat Python’s amazing collection of libraries. Cabal / hackage isn’t bad, but it doesn’t yet approach Python’s “batteries included” philosophy and ease of use. Anyway, I couldn’t [...]
Posted in coding, haskell, python | No Comments »
Wednesday, February 25th, 2009
I will be updating this as I go… but see also the Wikipedia page on string functions in various languages. Joining a string list [code lang='haskell'] -- Python: ",".join(lst) -- either... import Data.List intercalate "," lst -- or... import Data.List concat (intersperse "," lst) [/code] Splitting on a string [code lang='haskell'] -- a.split(ss) -- You [...]
Posted in coding, haskell | No Comments »