f#

What is the standard way to optimise mutual recursion in F#/Scala?

北城余情 提交于 2019-12-21 04:17:15
问题 These languages do not support mutually recursive functions optimization 'natively', so I guess it must be trampoline or.. heh.. rewriting as a loop) Do I miss something? UPDATE: It seems that I did lie about FSharp, but I just didn't see an example of mutual tail-calls while googling 回答1: First of all, F# supports mutually recursive functions natively, because it can benefit from the tailcall instruction that's available in the .NET IL (MSDN). However, this is a bit tricky and may not work

Seq.iter vs for - what difference?

纵饮孤独 提交于 2019-12-21 03:57:28
问题 I can do for event in linq.Deltas do or I can do linq.Deltas |> Seq.iter(fun event -> So I'm not sure if that is the same. If that is not the same I want to know the difference. I don't know what to use: iter or for . added - so if that is the matter of choice I prefer to use iter on a top level and for is for closures added some later - looking like iter is map + ignore - it's the way to run from using imperative ignore word. So it's looking like functional way ... 回答1: You can modify

Are there plans to support “type providers” for Scala's SIQ (ScalaIntegratedQuery) like in F#?

99封情书 提交于 2019-12-21 03:52:44
问题 The current state of SIQ was presented by Christopher Vogt at ScalaDays 2011. It was shown how queries would work and look like, but as far as I remember there was no notion about how those types would be represented, e. g. if it is still necessary to write boilerplate code to explain the database structure to Scala. F# 3.0 adds type providers (PDC talk by Don Syme: video; GOTO Copenhagen talk by Tomas Petricek: video, slides, blog post), which make it basically unnecessary to manually write

“int -> int -> int” What does this mean in F#?

匆匆过客 提交于 2019-12-21 03:49:13
问题 I wonder what this means in F#. “a function taking an integer, which returns a function which takes an integer and returns an integer.” But I don't understand this well. Can anyone explain this so clear ? [Update]: > let f1 x y = x+y ;; val f1 : int -> int -> int What this mean ? 回答1: F# types Let's begin from the beginning. F# uses the colon ( : ) notation to indicate types of things. Let's say you define a value of type int : let myNumber = 5 F# Interactive will understand that myNumber is

Why does the pipe operator work?

一笑奈何 提交于 2019-12-21 03:46:44
问题 If the pipe operator is created like this: let (|>) f g = g f And used like this: let result = [2;4;6] |> List.map (fun x -> x * x * x) Then what it seems to do is take List.Map and puts it behind (fun x -> x * x * x) And doesn't change anything about the position of [2;4;6] So now it looks like this: let result2 = [2;4;6] (fun x -> x * x * x) List.map However this doesn't work. I am just learning f# for the first time now. And this bothered me while reading a book about f#. So I might learn

Drawbacks of developing ASP.NET and ASP.NET MVC apps in F#?

对着背影说爱祢 提交于 2019-12-21 03:43:27
问题 I would like to try developing ASP.NET and ASP.NET MVC apps in F# . I enjoy using functional langauges, and to my mind the functional paradigm fits better with HTTP and the web than imperative programming (though of course F# can do both). I am only intending on trying F# for some personal projects, though I hope that eventually F# will be seen as a valid alternative to C# for suitable commercial ASP.NET projects. What pitfalls and rough edges are there currently for using F# with ASP.NET?

How can I enable a WinForms or WPF project in F#?

[亡魂溺海] 提交于 2019-12-21 03:17:10
问题 I have the very latest version of Visual Studio 2017 installed. I selected F# language support and F# desktop support. After restarting and going to File -> New Project I was expecting to see an option to start a new WPF or WinForms project for F# but I don't have any such options. Only console, library, ASP.NET core, and the tutorial. How can I enable or find the new project templates for F# desktop applications? 回答1: As far as I know, there are no "out of the box" templates for WPF or

In which language is F#'s compiler written?

青春壹個敷衍的年華 提交于 2019-12-21 03:14:21
问题 In which language is F#'s compiler written? I've heard that F#'s compiler is written in F# :) (each next version of F# compiler is written on its previous version) But: 1. Can't google if it's true. 2. If it's true, in which language is the first version of the F# compiler written? 回答1: The F# compiler is written in F#. The source code is available. It was originally bootstrapped years ago using OCaml, I believe (and perhaps a little C++ as well). (There is still a non-trivial subset of F#

convert .NET generic List to F# list

橙三吉。 提交于 2019-12-21 03:08:27
问题 Is there a built-in method to convert the .NET List<> into the F# list? 回答1: Try List.ofSeq in the Microsoft.FSharp.Collections namespace. # List.ofSeq : seq<'T> -> 'T list It's not specifically for System.Collections.Generic.List<T> , but for IEnumerable<T> ( seq<'T> in F#) types in general, so it should still work. (It's also not strictly built into the F# language, but neither is List<T> built into C# or VB.NET. Those are all part of the respective standard libraries.) 回答2: Given

Set a property on ViewBag dynamic object in F#

眉间皱痕 提交于 2019-12-21 02:28:16
问题 I have this action method in C#: public ActionResult Index() { ViewBag.Message = "Hello"; return View(); } And this view (Index.cshtml): <h2>@ViewBag.Message</h2> And this produces the expected "Hello" on the page. I want to do the controller in F#. I've tried type MainController() = inherit Controller() member x.Index() = x.ViewBag?Message <- "Hello" x.View() And this produces the error message "Method or object constructor 'op_DynamicAssignment' not found". I've looked at some of the F#