Are there tricks for doing implicit conversions in F#?

前端 未结 2 1350
挽巷
挽巷 2020-12-11 19:09

Consider this F# code to sum the numbers below i that are multiples of 3 and 5:

let isMultipleOfThreeOrFive n = 
    (n % 3 = 0) || (n % 5 = 0)
         


        
2条回答
  •  我在风中等你
    2020-12-11 20:00

    You did the best thing.

    (There is not an easier way to "get around" it than by adding the six characters you added. Even without implicit conversions, the F# is shorter than the C#, and the delta change-from-int-to-BigInteger is also smaller in F# than C#. So don't be sad about the loss of implicit conversion - be happy about all the other succinctness wins. :) )

提交回复
热议问题