casting - Domain.IntegerRange from MS Solver Foundation using F# -
i've been playing ms solver using f# , need define domain range of ints. learnt there's function: domain.integerrange takes 2 parameters of rational type.
in c# there's no problem using ints instead of rationals: http://msdn.microsoft.com/en-us/library/ff826356(v=vs.93).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1
however, in f# such implicit conversion doesn't accepted. how should implemented instead ? i've tried create somehow rational based on int, failed so.
the rational
class supports implicit conversions int, float, etc. , seamless in c#. f#, on other hand, not implicit conversions without asking them... well... explicity.
you can invoke op_implicit
operator directly want:
let rat (i:int) = rational.op_implicit(i) domain.integerrange(rat 6, rat 8)
it's possible define operator in general, see standard approach in tomas's answer this question.
Comments
Post a Comment