[Solved] Need Converting Help C# to F#

Something like this should do the trick: let getEnumDescription value = let fi = value.GetType().GetField(value.ToString()) let attributes = fi.GetCustomAttributes(typedefof<DescriptionAttribute>, false) |> Array.map (fun x -> x :?> DescriptionAttribute) if attributes.Length > 0 then attributes.[0].Description else value.ToString() Then you can call it like so: let red = Color.Red |> getEnumDescription let blue = Color.Blue |> getEnumDescription … Read more

[Solved] What is the answer to this list? [closed]

This is a really bad question. However, The last line in your code will fail with This expression was expected to have type int list list but here has type int .. because :: concatenates an element to a list. It can only do it from the front because the list is a singly linked … Read more

[Solved] how to create a seq value

There is more than one way to do this, but I like the seq builder: let positions = seq { for x in 0..10 do for y in 0..10 do yield (x, y) } solved how to create a seq value

[Solved] Getting started with basic transportation problems like Wolf, Cabbage, Goat with either C# or F# [closed]

I’d recommend going thru the excellent article Escape from Zurg: An Exercise in Logic Programming. Although the functional language of choice there is Haskell, it should give you enough ideas about programming of optimal search problems functionally. Also Escape from Zurg in Scala has full source code easily portable to F#. solved Getting started with … Read more

[Solved] F# : not sure how to start [closed]

3. type Line = {a:double; b:double} let LinesIntersection x y = if x.a <> y.a then Some ((x.b – y.b)/(y.a – x.a), (y.a*x.b – x.a*y.b)/(y.a – x.a)) else None let l1 = {a = 2.0; b = -3.0} let l2 = {a = -3.0; b = 2.0} let l3 = {a = 2.0; b = … Read more