Coincidence?

I ran across an interesting piece of Haskell code in a post on teideal glic deisbhéalach.

sum (map ord “al gore”)

Bryan O’Sullivan, the author of teideal glic deisbhéalach, attributes the code to diffbavis on #haskell. Mr O’Sullivan does not explain the code; his audience already reads Haskell. But I want to present this program to a wider audience.

ord is a function that takes a character as input and returns its ascii character code, an integer. For instance ord ‘a’ is 97.

In Haskell, the string “al gore” is identical to a list of characters, ['a','l',' ','g','o','r','e'].

Mapping the function ord over the list ['a','l',' ','g','o','r','e'] results in the list [97,108,32,103,111,114,101].

So map ord “al gore” evaluates to [97,108,32,103,111,114,101].
Then sum (map ord “al gore”) evaluates to sum [97,108,32,103,111,114,101] or 666.

3 Responses to “Coincidence?”

  1. Ord?

    You make this function sound arbitrary. In fact it returns the ASCII code, which is a standard that predates the birth of the inventor of the internet.

    I’m sure you’ll agree this is too important a fact to be omitted if we are to sensibly judge whether this carbon offsetting saint is in fact the anti-Christ.

  2. ooops.

  3. TDK,
    Your observation is absolutely dead on. So much so that I am going to amend the orginal article.

    When I first wrote the post it bothered me that my account of the evaluation process is in not in the true Haskell spirit : I ignore laziness. Then I thought, “no one who reads this will give a damn about the Haskell”. I am delighted to have been proven wrong.

    I took the liberty of closing a tag for you. I really need to make comments editable; likely there is a Wordpress plugin to enable this.

    Since you obviously appreciate numerological demonology, allow me to refer you to La Vida Loca.