f#-scripting

Can I install/reference packages from within an fsx file?

倾然丶 夕夏残阳落幕 提交于 2020-02-19 16:00:51
问题 I'm trying to find a simple solution that isn't so much manual work to reference packages. inside a .fsx file. LinqPad 4 lets me simply add nuget packages no intellisense or autocompletion deletes package after download for certain types of packages (templatus for example) LinqPad 5 beta lets me add nuget packages deletes package after download for certain types of packages (templatus for example) with frequent failures (intellisense and compilation) VS2015 doesn't let you download/install

Using COM DLLs with FSI

為{幸葍}努か 提交于 2020-01-16 08:16:14
问题 Is there a way within FSI that I can reference and use registered COM components? In a normal .fs compiled program I can simply reference the component in question and then open the relevant generated namespace(s). In a .fsx file, however, I can't seem to replicate this behaviour. I have tried using #r to reference the .dll directly, and I have tried using #I to point to the directory followed #r both with the library's "friendly" name and the file name, but nothing seems to work. Are you

What/where is get_Zero in F#'s int?

血红的双手。 提交于 2020-01-03 13:38:55
问题 I'm just learning F#, and while playing at tryfsharp.org I noticed that if I change this code: [0..100] |> List.sum to ["A"; "B"; "D"] |> List.sum I get the following error: The type 'string' does not support the operator 'get_Zero' (Here's the script that you can run/amend in your browser, though it only seems to work in IE for me!) When I checked the definition of List.sum; it says that the type must have a static member called Zero. This seems to explain the error; except for the fact that

How does fsi.ShowDeclarationValues work?

孤街醉人 提交于 2019-12-20 04:34:43
问题 According to the MSDN documentaion: When set to false, disables the display of declaration values in the output of the interactive session. However, the following sample interactive session seems to contradict that summary. > let x = 42;; val x : int = 42 > fsi.ShowDeclarationValues <- false;; val it : unit = () > let y = 42;; val y : int I was not expecting the last line above. Have I misunderstood something? Can anyone confirm if this is a bug? Thanks. 回答1: Daniel is correct - this disables

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

f# spacing and mergesort

…衆ロ難τιáo~ 提交于 2019-12-11 05:36:25
问题 I have this code provided by my instructor. I am supposed to fix it by finding what type f# infers from mergesort. When I try to send to interactive i get an error . I asked my proffesor what was wrong and he said that it was due to formatting errors on the class website. I have tried adding spaces removing spaces you name it but every time i get a ~vs4489.fsx(8,14): error FS0588: Block following this 'let' is unfinished. Expect an expression. on the last two methods. How can I fix this? Here

Use app.config from fsx file

天大地大妈咪最大 提交于 2019-12-08 19:58:40
问题 Is it possible to use an app.config file from a F# script (fsx) file? If so, how? Where do I put the file and what will it be called? 回答1: The linked question by @JoeB provides 2 answers which are more suited to F# Interactive than .fsx scripts. I provide a good solution for F# scripts below: Given this app.config file: <configuration> <appSettings> <add key="foo" value="bar"/> </appSettings> </configuration> Read foo this way: let appConfigPath = System.IO.Path.Combine(Directory

IntelliSense in .fsx and dynamically loaded assemblies

社会主义新天地 提交于 2019-12-07 01:58:47
问题 When dynamically referencing assemblies in .fsx using #I and #r , VS highlights the following usages of imported types and writes "The namespace or module 'XXX' is not defined". Is it ok? For example, in the following code #I @".\Tools\FAKE" #r "FakeLib.dll" open Fake Target "Hello" (fun _ -> trace "hello!") Run "Hello" VS highlights Fake and says "The namespace or module 'Fake' is not defined", it also highlights Target and Run . I have this problem in VS 2010 SP1 and in VS 11 CTP. This

Mergesort Getting an Error in F#

梦想与她 提交于 2019-12-04 06:48:52
问题 let rec merge = function | ([], ys) -> ys | (xs, []) -> xs | (x::xs, y::ys) -> if x < y then x :: merge (xs, y::ys) else y :: merge (x::xs, ys) let rec split = function | [] -> ([], []) | [a] -> ([a], []) | a::b::cs -> let (M,N) = split cs (a::M, b::N) let rec mergesort = function | [] -> [] | L -> let (M, N) = split L merge (mergesort M, mergesort N) mergesort [5;3;2;1] // Will throw an error. I took this code from here StackOverflow Question but when I run the mergesort with a list I get an

Mergesort Getting an Error in F#

断了今生、忘了曾经 提交于 2019-12-02 12:06:08
let rec merge = function | ([], ys) -> ys | (xs, []) -> xs | (x::xs, y::ys) -> if x < y then x :: merge (xs, y::ys) else y :: merge (x::xs, ys) let rec split = function | [] -> ([], []) | [a] -> ([a], []) | a::b::cs -> let (M,N) = split cs (a::M, b::N) let rec mergesort = function | [] -> [] | L -> let (M, N) = split L merge (mergesort M, mergesort N) mergesort [5;3;2;1] // Will throw an error. I took this code from here StackOverflow Question but when I run the mergesort with a list I get an error: stdin(192,1): error FS0030: Value restriction. The value 'it' has been inferred to have generic