f#

Redirecting stdin and stdout in .Net

。_饼干妹妹 提交于 2019-12-30 04:58:13
问题 I'm trying to redirect stdin and stdout of a console application, so that I can interact with them via F#. However, depending on the console application the obvious code seems to fail. The following F# code works for dir but fails (hangs) for python and fsi : open System open System.Diagnostics let f = new Process() f.StartInfo.FileName <- "python" f.StartInfo.UseShellExecute <- false f.StartInfo.RedirectStandardError <- true f.StartInfo.RedirectStandardInput <- true f.StartInfo

Typed abstract syntax tree with function application

烂漫一生 提交于 2019-12-30 04:56:09
问题 I am trying to write a typed abstract syntax tree datatype that can represent function application. So far I have type Expr<'a> = | Constant of 'a | Application of Expr<'b -> 'a> * Expr<'b> // error: The type parameter 'b' is not defined I don't think there is a way in F# to write something like 'for all b' on that last line - am I approaching this problem wrongly? 回答1: In general, the F# type system is not expressive enough to (directly) define a typed abstract syntax tree as the one in your

f# read xls file - how to parse a value2 object

纵饮孤独 提交于 2019-12-30 04:49:08
问题 I tried to use F# read a xls file as below open Microsoft.Office.Interop.Excel let app = ApplicationClass(Visible = false) let book = app.Workbooks.Open "test.xls" let sheet = book.Worksheets.[1] :?> _Worksheet let vals = sheet.UsedRange.Value2 The problem is how can I parse vals into a F# type? in fsx.exe, the vals showed as 'val vals: obj = [bound1 bound2 ["colname1"; "colname2"; ...] [1234,5678,]...] I wanted to retrieve the string represetation first, but printfn "%A" vals.ToString();;

Int and String F# [closed]

本秂侑毒 提交于 2019-12-30 04:38:04
问题 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 have a function in F#, where I take an int value and return the int as a string . let inttostring (x:int):string = ""+x I can't get

F# Quality of Life Questions

廉价感情. 提交于 2019-12-30 04:00:38
问题 I started coding in F# about 2 months ago. I am greatly enjoying this programming language. I come from a C# background, and every time I need to revert back to C#, it feels so cumbersome and bloated. But there are still things I think are problematic in F#, and this is what my questions are related to: There is no auto complete like VS has for C# right ? E.g. inside a function that takes parameter aParameter, if I write aPara no auto complete comes up. Is there a functionality inside VS that

Type of addition (+) in F#

房东的猫 提交于 2019-12-30 03:03:08
问题 I just learned that OCAML have to have a . postfix for doing float arithmetic. An example would be 3. +. 4. which equals 7. (float). However, F# handles float and integer arithmetic in the same way, so both 3 + 4 (int) and 3. + 4. (float) works. F# have + naturally assigned to int so let add a b = a + b is of type int -> int -> int . And indeed (+) gives me val it : (int -> int -> int) = <fun:it@6-1> . That leads to the following sequence which I think quite counter-intuitive: > 3. + 4.;; val

Generating Fibonacci series in F#

一曲冷凌霜 提交于 2019-12-30 02:46:07
问题 I'm just starting to learn F# using VS2010 and below is my first attempt at generating the Fibonacci series. What I'm trying to do is to build a list of all numbers less than 400. let fabList = let l = [1;2;] let mutable a = 1 let mutable b = 2 while l.Tail < 400 do let c = a + b l.Add(c) let a = b let b = c My first problem is that on the last statement, I'm getting an error message "Incomplete structured construct at or before this point in expression" on the last line. I don't understand

F# type provider - “only return generated types”

安稳与你 提交于 2019-12-30 02:00:12
问题 Trying to encode type-level peano numbers using a type provider: namespace TypeProviderPlayground open System open Microsoft.FSharp.Core.CompilerServices open System.Runtime.CompilerServices [<assembly: TypeProviderAssembly()>] do() type Z = class end type 'a S = class end type N = class end [<TypeProvider>] type PeanoProvider(s: TypeProviderConfig) = let invalidate = Event<_,_>() interface ITypeProvider with member x.ApplyStaticArguments(typeWithoutArguments, typeNameWithArguments,

Functional languages (Erlang, F#, Haskell, Scala)

最后都变了- 提交于 2019-12-29 18:50:10
问题 1) Are functional languages suited for web applications development? 2) Are functional languages suited for business/ERP/CRM type of applications? 回答1: Functional languages of the kind you describe are general purpose programming languages, they're used for all manner of things, including web apps and business apps. (I use Haskell). Is Haskell good for Web Apps? Building commerical web apps in Haskell As gabor implies, ultimately it comes down to libraries. Scala has a web framework: lift.

How do I use Travis-CI with C# or F#

天涯浪子 提交于 2019-12-29 10:05:18
问题 Travis CI continuous integration service officially supports many languages, but not C# or F#. Can I use it with my .net projects? 回答1: Travis CI now supports C#. Quoting liberally from that page: Overview The setup for C#, F#, and Visual Basic projects looks like this: language: csharp solution: solution-name.sln mono: - latest - 3.12.0 - 3.10.0 Script By default Travis will run xbuild solution-name.sln. Xbuild is a build tool designed to be an implementation for Microsoft's MSBuild tool. To