f#

groupby multiple columns in a F# 3.0 query

我怕爱的太早我们不能终老 提交于 2019-12-18 11:00:34
问题 Just trying out F# 3.0 and hit a bit of a wall when it comes to grouping by multiple columns. The obvious thing to try was query { for d in context.table do groupBy (d.col1,d.col2) into g select (g.Key) } But I get a "Only parameterless constructors and initializers are supported in LINQ to Entities." exception. I can't seem to find an example on msdn http://msdn.microsoft.com/en-us/library/hh225374(v=vs.110).aspx http://msdn.microsoft.com/en-us/library/hh361035(v=vs.110).aspx And I realize

F# code organization: types & modules

限于喜欢 提交于 2019-12-18 10:42:53
问题 How do you decide between writing a function inside a module or as a static member of some type? For example, in the source code of F#, there are lots of types that are defined along with a equally named module, as follows: type MyType = // ... [<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] module MyType = // ... Why don't you simply define the operations as static members of type MyType? 回答1: Here are some notes about the technical distinctions. Modules can be

F# code organization: types & modules

折月煮酒 提交于 2019-12-18 10:42:25
问题 How do you decide between writing a function inside a module or as a static member of some type? For example, in the source code of F#, there are lots of types that are defined along with a equally named module, as follows: type MyType = // ... [<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] module MyType = // ... Why don't you simply define the operations as static members of type MyType? 回答1: Here are some notes about the technical distinctions. Modules can be

In what areas does F# make “absolute no sense in using”? [closed]

时光怂恿深爱的人放手 提交于 2019-12-18 10:31:36
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 years ago . Don Syme in his SPLASH talk says that F# is NOT intended to be a replacement for C# even though it has the general capabilities. He goes on to say that there are areas where F# makes no sense in using, but doesn't expand on the thesis. Can somebody please tell me what areas

If Java people go to Scala, C# go to F#, where do Ruby people go for functional nirvana? [closed]

我是研究僧i 提交于 2019-12-18 10:12:09
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I know a lot of Java people have started looking at Scala since it runs on the JVM, and a lot of people in the Microsoft world are

Passing a seq<string option> from F# to RProvider

随声附和 提交于 2019-12-18 09:37:29
问题 I asked this question last week regarding seq<float option> values passed to RProvider. I had hoped that I'd be able to apply the accepted answer there to other option types in F#. Unfortunately, NaN is only applicable to numeric in R. How can I convert a None string in F# to NA and pass to R? 回答1: You can use Option.toObj . For example: let l1 = [ Some "x"; None; Some "y"] let l2 = l1 |> List.map (Option.toObj) // val l2 : string list = ["x"; null; "y"] And you can use Option.toNullable for

F#: Recursive Functions: concatenate 2 lists which have common elements

二次信任 提交于 2019-12-18 09:12:47
问题 So here is what I have so far. It feels close but im not sure how to fix the problems in line 84 (2nd to last line: elif List.append(isolate(a),isolate(b)) != [] then List.append(isolate(a),isolate(b))). (* val isolate : l:'a list -> 'a list when 'a : equality *) let rec isolate (l:'a list) = match l with | [] -> [] | x::xs -> if memberof(x,xs) then let xs = remove (x,l) isolate xs else isolate xs ( * val common : 'a list * 'a list -> 'a list when 'a : equality *) let rec common (k: 'a list,

F#: Why is Array.createZero so fast?

一笑奈何 提交于 2019-12-18 09:03:07
问题 I have this code: let timer = new System.Diagnostics.Stopwatch() timer.Start() Array.zeroCreate<int> 100000000 timer.Stop() printfn "%ims" timer.ElapsedMilliseconds timer.Reset() timer.Start() Array.create 100000000 0 timer.Stop() printfn "%ims" timer.ElapsedMilliseconds I tested it and had these results: 0ms 200ms How does Array.zeroCreate create array so fast and it's guaranteed that all it's elements have default value? In other languages I know there are no such possibilities (as far as I

printf style logging for f#

假装没事ソ 提交于 2019-12-18 08:55:32
问题 How do i setup a printf-style logger for f# using logging library similar to log4net. i have Log.Debug, Info, Warn, etc. functions that are similar to DebugFormat or InfoFormat in log4net. i tried to setup type extensions for my Log class that i could call in printf style like Log.Debugf "%s" "foo". my generic log function looks like this: let log format = Printf.kprintf (sprintf "%s") format i am having trouble with the extension function signature to log to my Debug function... i tried

Using PostSharp with F# - Need documentation with working example

北城以北 提交于 2019-12-18 08:49:50
问题 I have a need to capture the input and output of F# functions and decided to try using PostSharp. I was unable to find documentation and a working F# example for using PostSharp with F#. Does anyone know where I might find such? 回答1: PostSharp does not officially support F#. It may partially work, because PostSharp works at MSIL level, but there's no guarantee that everything will work, and since it is not supported, bugs will not be solved. 来源: https://stackoverflow.com/questions/14653231