As part of my ongoing interest in functional programming languages, I have decided to try F#. I have been looking at the Try F# page:
At first glance, I quite like the learning experience of reading through explanations and running some code, although it’s not as much fun as trying to make something yourself. In order to consolidate my learning, I tried to solve the first of the problems in Project Euler, which is to find the sum of the natural numbers less than 1000 that are multiples of 3 or 4. (I have already done this in Haskell).
I came up with this:
[0..999] |> List.filter (fun x -> x % 3 = 0 || x % 5 = 0) |> List.sum