Added alternative F# implementation.