f#

Can't add reference from C# PCL project to F# PCL project as project reference

﹥>﹥吖頭↗ 提交于 2019-12-11 12:59:03
问题 I wanna add project reference from Xamarin.Forms PCL C# project to F# PCL project, but Visual Studio15 shows alert as "Unable to add a reference to project 'PortableLibrary2'. Portable Library projects can only reference other Portable Library projects and assemblies." If I use Visual Studio13,it shows "Unable to add a reference to project 'PortableLibrary2'." then 'The method or operation is not implemented.'. I attached link to sample project on github I created this sample with following

Expensive Asynchronous Reading of Response Stream

末鹿安然 提交于 2019-12-11 12:42:54
问题 I have been trying to learn F# for the past couple of day and I keep running into something that perplexes me. My "learning project" is a screen scraper for some data I'm kind of interested in manipulating. In F# PowerPack there is a call Stream.AsyncReadToEnd. I did not want to use the PowerPack just for that single call so I took a look at how they did it. module Downloader = open System open System.IO open System.Net open System.Collections type public BulkDownload(uriList : IEnumerable) =

Tail Recursive Combinations

☆樱花仙子☆ 提交于 2019-12-11 12:33:27
问题 I have this code: let rec combinations acc listC = match listC with | [] -> acc | h::t -> let next = [h]::List.map (fun t -> h::t) acc @ acc combinations next t It looks tail recursive, but I keep getting stack overflows with it. Any ideas on how to make it work? 回答1: combinations is tail recursive. Your problem is with the @ operator. Appending a list with it iterates the whole list, so as your acc becomes large, you will get a SO. You can see here, that the @ operator is not tail recursive.

How is F#'s static bound constraints implemented?

随声附和 提交于 2019-12-11 12:18:53
问题 In F#, you can perform black-magic voodoo 1 and perform static typed constraints to ensure a function is only called on types that have the member constraints. For example: module Collection let inline init s = let collection = new ^t() let add e = (^t : (member Add : 'a -> unit) collection, e) Seq.iter add s collection This function can be called where a type that has an Add<'a> that has the signature 'a -> unit . Usage: let a:List<_> = Collection.init {1..10} let b:SynchronizedCollection<_>

Unicode_escape_decode() takes no arguments error when run python in F#

筅森魡賤 提交于 2019-12-11 12:06:37
问题 To run python script with F#, got error, if just run the python script, it do not have error, however put it in F#, it has error or run a very long time In order to solve error Unicode_escape_decode() takes no arguments I convert to ASCII and got the same error Then add code import codecs def my_unicode_escape_decode(x): return x codecs.unicode_escape_decode = my_unicode_escape_decode In the script to be run, it runs a very long time, have not ever stoppped since run let scoperesult = script

Compiler can't tell which record type with duplicate fields should be the function parameter type

杀马特。学长 韩版系。学妹 提交于 2019-12-11 11:56:19
问题 My program has a few record types with the same field names (each record type means something different). The compiler insists function parameters matching this record shape must be of the last type declared, even though I'm declaring record instances with unambiguous field names, and always passing a consistent type into each function. What is the appropriate way to deal with this? I know I could put a type annotation on the functions, but I feel like if I'm doing things the Right Way, I

How do you add a description to a FAKE Target?

坚强是说给别人听的谎言 提交于 2019-12-11 11:54:49
问题 Is it possible to add a description to this target? Or would I have to go about it another way? Target "Test" (fun _ -> trace "Testing stuff..." ) Edit: TargetHelper allows for the description to be shown when listTargets() is called. At least, that's my understanding from the code here: https://github.com/fsharp/FAKE/blob/master/src/app/FakeLib/TargetHelper.fs#L360-L365 回答1: If you just want to make your build script readable, you can add a comment in the normal F# way: // Tests some stuff

Clean Code in Excel?

两盒软妹~` 提交于 2019-12-11 11:47:46
问题 As a former programmer I like clean, maintainable and documented code. As a project manager I have to do complex excels from time to time and want to write "clean" formulas in the same way I wrote programs. (How) Can I add "comments" into a (multiline) formula? (How) Can I "name" a (cell-relative) formula and reuse it? (e.g. write it as a vb (or even f#) function with parameters) Example1: Instead of =IF(AND(L$11+(L$13-1)*7>=$C15;L$11+(L$13-1)*7<$D15);VLOOKUP($A15;RessourcePlan;12+$E15;WRONG)

How to send this PUT-request to prestashop?

喜欢而已 提交于 2019-12-11 11:45:01
问题 I am working with Prestashop web service. I am trying to send a PUT (update) request to the API but with no luck. My request seems to be set up in the 'wrong' way (i.e. not in the way the server expects) Since Prestashop is open-source I took a look at the source code, specifically when it recieves a PUT request it does the following (I don't write php-code): $input_xml = null; // if a XML is in PUT or in POST if (($_SERVER['REQUEST_METHOD'] == 'PUT') || ($_SERVER['REQUEST_METHOD'] == 'POST')

is there any way to simplify this line?

五迷三道 提交于 2019-12-11 11:34:53
问题 if reelID = reelWeights.Count - 1 then Array.fold calc1 (0L,0) reelWeights.[reelID] else Array.fold calc2 (0L,0) reelWeights.[reelID] I tried use pipeline, it seems to slow down a little bit (not sure why): reelWeights.[reelID] |> (if reelID = reelWeights.Count - 1 then Array.fold calc1 else Array.fold calc2) (0L,0) if I do let calc x = if x then calc1 else calc2 Array.fold (calc reelID = reelWeights.Count - 1) (0L,0) reelWeights.[reelID] then it looks nice at the cost of redundantly check