f#

F# best way to set up a SQLCommand with parameters

扶醉桌前 提交于 2019-12-12 19:13:11
问题 My F# program needs to talk to SQL Server. In one part I have something like this: let workFlowDetailRuncommand = new SqlCommand(query, econnection) workFlowDetailRuncommand.CommandTimeout <- 100000 workFlowDetailRuncommand.Parameters.Add("@1", SqlDbType.Int).Value <- 42 workFlowDetailRuncommand.Parameters.Add("@2", SqlDbType.VarChar).Value <- "answer" workFlowDetailRuncommand.Parameters.Add("@3", SqlDbType.VarChar).Value <- mydate.ToString("yyyy.MM.dd") workFlowDetailRuncommand.Parameters

VisualStudio 2017 refactor doesnt work for F#

空扰寡人 提交于 2019-12-12 19:05:35
问题 I have project in F# , i'm working on VisualStudio2017 . I tried to refactor the code and use inline, but this menu item is unavailable. Also when i click Rename nothing happened. Why it is unavailable? How to force refactor operation to work? let blobToBlobWithInfo (b:IListBlobItem ) = try let blobUri = b.Uri.ToString() let blobUriParts = blobUri.Split '/' let t = Array.length blobUriParts let integrationName = blobUriParts.[t-2] if(integrationName <> "LogsToBlobService") then let logTime =

F# : Writing a function that builds a list of tuples recursively, a syntax error

眉间皱痕 提交于 2019-12-12 18:46:50
问题 I'm trying to write a recursive function that return a List < int * int>, but I'm having some trouble with the syntax. The function should return an empty list when the recursione ends, otherwise a tuple (int * int) merged with a List returned by a recursive call to itself: let rec foobar () : List<int * int> = if (recursionIsEnded) then [] else foobar () :: (10, 10) // this is wrong // (10,10) works, but I need to concatenate it with the elements returned by foobar recursive call Could

F#: Recursive functions: Split a list into two equal parts

假装没事ソ 提交于 2019-12-12 18:46:44
问题 I'm having some errors with split and mergesort. (Note this is a formatted assignment requiring specific input & output types for each function) Here is my code right now: (* val split : l:'a list -> 'a list * 'a list *) let split (l:'a list -> 'a list * 'a list) = let rec splitInner = function | [],[] -> [],[] | x::xs, acc -> if xs.Length>(acc.Length) then splitInner (xs x::acc) else xs acc splitInner (l, acc) error FS0001: This expression was expected to have type 'a list * 'b list but here

F#: Recursive Functions: Concatenating the common values between two lists

谁说我不能喝 提交于 2019-12-12 18:45:09
问题 let rec common a b = match isolate(a) b with | (x::xs,isolate(b)) -> if memberof(b x) then [x,common(xs b)] else common(xs b) Here is what I have right now, but I've been trying many different things. The memberof() takes a float list and a float and returns true if the float is a member of the float list. The memberof() function works. I can't figure out how to return the new list. I also have an isolate() function which will take a list and remove any duplicate floats within the list. This

Is is possible to convert this recursive function to tail-recursive using continuation passing style?

自作多情 提交于 2019-12-12 18:26:41
问题 I have recently written an ETL, which works just fine. I would like to remind myself how to use free monads, so would like to convert my ETL as such. Note: my intention here is not to write a better ETL, but to re-familiarize myself with free monads. In re-learing how free monads work, I got side tracked with the topic of this question. So I asked a related question some months ago. Someone commented that my recursive function could be made tail-recursive using continuation passing style. I

Why am I getting a MissingMethodException when calling F# code from PowerShell?

馋奶兔 提交于 2019-12-12 18:25:05
问题 I'm trying to use PowerShell to call some F# code which uses Akka.Net actors. The F# code works fine in unit testing and when run from the F# interpreter, but when I call the same code from a PowerShell cmdlet I get the following exception: System.MissingMethodException: Method not found: 'Void Nessos.FsPickler.BinarySerializer..ctor(Microsoft.FSharp.Core.FSharpOption`1<Boolean>, Microsoft.FSharp.Core.FSharpOption`1<Nessos.FsPickler.ITypeNameConverter>)'. at Akka.FSharp.Serialization

F# Excel UsedRange has no Properties or Methods

。_饼干妹妹 提交于 2019-12-12 18:04:03
问题 This is a continuation of the discussion begun on F# Excel UsedRange is not Defined, which has been solved by down-casting the ActiveSheet object to a Worksheet. Upon doing that, however, I was presented with a new problem: UsedRange exposes no properties or methods other than the standard object methods. My solution has references to Microsoft.Office.Interop.Excel and Microsoft.Office.Tools.Excel.v4.0.Utilities. open Microsoft.Office.Interop.Excel open Microsoft.Office.Tools.Excel let xl =

F#/C# - fsx Script Files and Project References

主宰稳场 提交于 2019-12-12 17:44:59
问题 You have a solution with one C# project in it. SomeComp.Framework is the name. You add a F# project to the solution. You reference the SomeComp.Framework project in the F# project. You insert a script file - test.fsx into the F# project. What is the correct way to reference the C# assembly in the script file? #r "SomeComp.Framework.dll" // doesn't work Is there some way to do this without hardcoding a path? Does the .fsx file get any settings/properties from being located inside a F# project?

F# Make Bar Chart with Winforms DataVisualization

☆樱花仙子☆ 提交于 2019-12-12 17:24:19
问题 I want to make a bar Chart with Winforms and F#. I have seen many other C# examples making a chart with System.Windows.Forms.DataVisualization.Charting although when i try to open that library then it says then namespace is not defined. Something as simple as this let chart = new Chart() doesn't work due to the namespace of the library not being defined i take it. Though I have seen people do this in C#. What is the correct way for F#? Can someone be so kind to show me how to make a chart in