added F# versions of the code