F# subreddit

I created an F# subreddit for F# news/links.

I find Reddit’s programming subreddit to be lacking recently, mostly because it seems ALL submissions get downvoted to 0 initially by bots and then only a few articles make it out of the hole. I’m not sure if this is just the current state of the programming subreddit or if it has something to do with the recent explosion of subreddits since they unlocked the ability to create your own.

Comments

Zeepf, a new metasyntatic variable.

You’ve most likely seen the words “Foo” and “Bar” used in nonsensical ways (e.g. as a silly variable, or a nonsense word). Both foo and bar belong to a bigger list of what is known as Metasyntatic Variables.

The list consists of the words “foo, bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy and thud”. Most of these metasyntatic variables originated from MIT, and others are from Stanford, CMU, Berkeley, and other universities. (For a more detailed history, see RFC 3092)

Guy L. Steele Jr., noted computer scientist and writer of many language specifications, is also known as “The Great Quux”, an obvious reference to metasyntatic variables.

In Steele’s latest language specification for Fortress, a new metasyntatic variable popped up, “Zeepf”. Googling for “zeepf” returns only references to Fortress source code, where it is used along with the more standard foo and bar.

I wonder what the origins of this new variable are, and for how long it has been used?

Comments

Amarok Now Playing in Psi with PEP

I found this script a while back to display what music Amarok was playing in Psi (You need Psi version 0.11 or later to support the PEP stuff).

EDIT: See the comments for Caustiq’s proper package for Amarok!

EDIT2: See the comments for Jean-Marc Liotier’s updated package that’s (almost) compliant with XEP-0118!

The script, however, didn’t differentiate between streams and MP3s. Caustiq and I modified it to display differently if you are listening to a stream or an MP3.

# Authors: Silian Della Ragione
#          Andres Gomez Garcia <agomez@igalia.com>
#          Antoine <Alan71> Gassot <antoine_dot_gassot_at_gmail_dot_com>
#          Modification by 'Albert'
#          (04/02/08) Modified to fix stream/mp3 tune strings by mbishop <mbishop@esoteriq.org>
# Version: 0.0.3
# License GNU/GPL
############################################################################
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
#########################################################################

#!/bin/bash

change () {
    title=`dcop amarok player title`
    artist=`dcop amarok player artist`
    album=`dcop amarok player album`
    track=`dcop amarok player track`
    time=`dcop amarok player totalTime`
    type=`dcop amarok player type`

    if [ "$type" = "Stream" ];
      then tune=”${title} - ${album}”
      else tune=”${artist} - ${title} - ${album} - ${time}”
    fi

    echo ${tune} > ~/.psi/tune
}

stop () {
    rm ~/.psi/tune
}

terminate () {
    stop
    exit 0
}

trap terminate 0 1 2 5 15

while [ 1 ]
do
    read input
    input=$(echo $input | sed -e ’s/engineStateChange:\ //’)
    case “$input” in
    “playing” | “trackChange” )
        change
        ;;
    “paused” | “empty” | “idle” )
        stop
        ;;
    esac
done

Comments (8)

Fibonacci numbers in F#

I typically write a few simple programs in any new language. I mostly write the standard ones: factorial, a guessing game, fibonacci numbers, etc.

Here I have my F# code for Fibonacci numbers. I also write (when it’s applicable) an arbitrary precision version, to print out integers larger than those that can be stored in a regular integer type.

#light

let fib n =
    let rec fib_aux (n, a, b) =
        match (n, a, b) with
          | (0, a, b) -> a
          | _ -> fib_aux (n - 1, a + b, a)
    fib_aux (n, 0, 1)

This Fibonacci code is properly tail recursive, and uses a helper function.

However, it will overflow and return negative numbers after a certain point.

> fib 20;;
val it : int = 6765
> fib 200;;
val it : int = -552082539

We can get arbitrary precision using BigInts. In F#, this is done very easily (we don’t even have to open Math.BigInt!).

let big_fib n =
    let rec big_fib_aux (n, a, b) =
        match (n, a, b) with
          | (0, a, b) -> a
          | _ -> big_fib_aux (n - 1, a + b, a)
    big_fib_aux (n, 0I, 1I)

Notice how all we need to do is use the “I” literal in the tail call for the numbers in the tuple.

> big_fib 20;;
val it : bigint = 6765I
> big_fib 200;;
val it : bigint = 280571172992510140037611932413038677189525I

Comments

F# is neat!

I’ve always liked Ocaml, but recently I started looking into F#. It seemed neat, and even worked on Mono when I tried it out last year. Now that my desktop system runs Windows (my laptop still runs Linux, thankfully) I wanted to use F# in it’s natural habitat, so I installed Visual Studio 2008 Shell.

VS 2008 Shell is a “bare bones” version of Visual Studio. It doesn’t have C# or any other language support, but it does allow you to use “plug ins”, which is what F# does. After you install VS 2008 Shell, you need to install F# (the latest as of this writing is 1.9.3.14). After that, create an F# project and you’re on your way.

Here are some helpful links involving F#:

Comments

Just a note…

If you came to my site looking for the PDF of “All About Monads”, I no longer have it up, but there is an HTML (and more up to date) version at haskell.org.

Comments

Cheb i Sabbah

Last week I bought DJ Cheb i Sabbah’s latest album Devotion. It’s a fantastic album. A great blend of eastern and modern music, with some really nice beats.  Highly recommended!

Comments

Weblogs, oh my!

So I just installed Wordpress on my dreamhost account. Huzzah!

Comments