f#

What APIs to use for implement CSP / GoRoutines in .NET/F#

故事扮演 提交于 2019-12-12 03:32:04
问题 I return to .NET after leave for a while in the 2.0 days. Now, I see a lot of APIs/libraries to manage concurrency in .NET. I like how GoRoutines feel and wish to have something alike in .NET/F#, but I'm unsure about what will be the better foundation for it. Is important to remember that goroutines work for both IO-bound and CPU-bound scenarios. P.D: I have full control of the codebase, and last .NET versions for F#/.NET in both windows & mono 来源: https://stackoverflow.com/questions/35493139

How do I print out lines recursively from a text file along with the average value of total elements from per line?

心不动则不痛 提交于 2019-12-12 03:26:05
问题 I know this question sounds a bit challenging, but hey I find nothing like this relates with F sharp here. Okay so, since in my previous question I mentioned I'm new to F#. Thanks to several of fellow programmers' helps here to solve my sum function in my previous question. So, I have a text file that contained more than 20 lines and I want to print out lines with year and average of total elements from each year and its elements. Sample text lines 2009 1.3 3.51 6.76 5.80 4.48 5.47 2.06 4.3 0

Trouble with Set.forall F#

空扰寡人 提交于 2019-12-12 03:17:04
问题 I'm having trouble trying to compare an element to all elements of a set. I want to write a boolean function that returns true if an element is not a neighbour and false if an element is a neighbour. We want to colour the chart so that two countries that share a border are not given the same colour. I will explain it with code type Country = string;; type Chart = Set<Country*Country>;; type Colour = Set<Country>;; type Colouring = Set<Colour>;; (* This is how you tell that two countries are

Sharing types across F# .fsx files

早过忘川 提交于 2019-12-12 02:37:54
问题 Is there a way to share types across fsx files? When using #load to load the same file containing a type from multiple FSX files they seem to be prefixed into a different FS_00xx namespace each time, which means you can't pass them around. Are there any ways around this behaviour without resorting to compiling into an assembly? 回答1: As for http://msdn.microsoft.com/en-us/library/dd233169.aspx [.fsx files are] used to include informal testing code in F# without adding the test code to your

Why won't my computer let me greet my customers?

≡放荡痞女 提交于 2019-12-12 01:59:46
问题 I am writing an application to replace our technical support department. When a customer needs technical support, we will simply mail him a floppy disk containing this application, which he can simply put into his computer hole and install it. They just type in their problem and the program will output the solution. I tried writing it in F#, but F# doesn't like it. I wrote this simple recursive function that shows a greeting message to the customer, but F# tells me "no, this code is bad". I'm

The type 'XmlProvider<…>.Parameter' does not support the operator 'get_Value'?

旧城冷巷雨未停 提交于 2019-12-12 01:49:26
问题 How to fix the code? Is the inline/Statically Resolved Type the same powerful as structural typing? The type 'XmlProvider<...>.Parameter' does not support the operator 'get_Value'? let input1 = """<r1><parameters><parameter name="token">1</parameter><parameter name="other">xxx</parameter></parameters><othersOf1>..sample....</othersOf1></r1>""" let xml1 = XmlProvider<"""<r1><parameters><parameter name="token">1</parameter><parameter name="other">xxx</parameter></parameters><othersOf1>...<

Combining same length arrays into one 2d array in f#

牧云@^-^@ 提交于 2019-12-12 01:23:15
问题 I have asked this question before in c# here and there wasnt really a succinct way of doing this. I m now trying to do the same in fsharp and see how that goes. I have two arrays that are same length and type and I would like to combine them into one with same length and 2 columns. I have this code that does this: let twoDimensionalArray (arr1:array<'a>) (arr2:array<'a>) = let rws = arr1|> Array.length Array2D.init rws 1 (fun i j -> arr1.[i], arr2.[i]) To be honest this surprises me a bit as

F# Excel UsedRange is not Defined

巧了我就是萌 提交于 2019-12-12 01:15:51
问题 Error: "The field, constructor or member 'UsedRange' is not defined". Code excerpts: open Microsoft.Office.Interop.Excel open Microsoft.Office.Tools.Excel // Onorio's excellent suggestion didn't fix code until this line was added. // Once the above line was added, Onorio's suggestion worked, // but now F# says "The field, constructor or member 'EntireColumn' is not defined". let xl = ApplicationClass() xl.Workbooks.OpenText(... let wb = xl.Workbooks.Item(1) let ws = wb.ActiveSheet :?>

F# Interactive Pass ParamArray of Functions

流过昼夜 提交于 2019-12-12 01:08:11
问题 I'm trying to expand on James Hugard's post How do I plot a data series in F#? and I'm running into a glitch when using a variable number of function arguments. If I specifically name out the functions for Hugard's LineChartForm like in this example, the code works as expected when loaded into the F# Interactive Interpreter: (* This code is based off of a Stack Overflow post by James Hugard @ https://stackoverflow.com/questions/3276357/how-do-i-plot-a-data-series-in-f *) module HuggardPlot #r

Microsoft Accelerator library with Visual Studio F#

走远了吗. 提交于 2019-12-12 00:49:48
问题 I've downloaded and installed Microsoft Accelerator as stated in the manual, but when I try to create a project that uses open Microsoft.ParallelArrays , ParallelArrays is still not defined. I tried going through the References to add Accelerator to the list but could not seem to find it. What am I doing wrong? Edit: I have found a file in another location that does work, but when I compile and run my test program it throws the error Unhandled Exception: System.DllNotFoundException: Unable to