f#-interactive

Convert tree to list

空扰寡人 提交于 2019-12-14 04:12:42
问题 How can I convert a tree to a list: So far I have the following code but its giving several issues: type 'a tree = Lf | Br of 'a * 'a tree * 'a tree;; let rec elementRight xs = function | LF ->false | Br(m,t1,t2) -> if elementRight xs t1 = false then t1::xs else element xs t1;; //cannot find element let rec elementLeft xs = function | LF ->false | Br(m,t1,t2) -> if elementLeft xs t2 = false then t2::xs else element xs t2 ;; //cannot find element let rec element xs = function | LF ->[] | Br(m

Type reference error using F# interactive

谁都会走 提交于 2019-12-13 17:42:17
问题 I have a solution consisting of 2 projects: Utilities - This project contains type MyMatlab and references a COM (TLP) reference Matlab Application (Version 7.11) Type Library LBM - This project contains function displayMyMatlab which uses the MyMatlab type from the Utilities project and thus this project references Utilities I create a fsx file containing: #r @".\bin\Release\LBM.dll" #r @".\bin\Release\Utilities.dll" LBM.displayMyMatlab() and I get following error: Microsoft (R) F# 2.0

Reading value from XML file Throws an error - FAKE F#MAKE

左心房为你撑大大i 提交于 2019-12-13 17:21:01
问题 I am trying to read value from XML file from FAKE , But I am getting an error i.e. .fsx(9,16) : eror FS000: Incomplete structurd construct at or before this point in expression. Expected '->' or other token. Below is my code , I am using XMLHelper.XMLRead to read values from xml file . #r "./packages/FAKE/tools/FakeLib.dll" open Fake open Fake.XMLHelper Target "BuildMain" (fun _ -> for s in XMLHelper.XMLRead true "D:/test/Version.Config" "/version/major/minor" trace s) "BuildMain"

Embedding F# Interactive throw System.Exception: 'Error creating evaluation session: StopProcessingExn None'

梦想的初衷 提交于 2019-12-13 13:48:59
问题 I'm working through the Embedding F# Interactive example from here but like this post, I'm having an issue with the following line throwing an exception: let fsiSession = FsiEvaluationSession.Create(fsiConfig, allArgs, inStream, outStream, errStream) The exception thrown is: "System.Exception: 'Error creating evaluation session: StopProcessingExn None'" My project is being run from VS2017 Enterprise, setup as a simple F# console app, with the Target Framework as .NET Core 2.0 . The version of

Missing namespace while running F# script from command line

天大地大妈咪最大 提交于 2019-12-13 05:19:08
问题 I am trying to follow this linke http://msdn.microsoft.com/en-us/library/hh361033.aspx to run the a database query via SqlDataConnection from a F# script which is triggered via a command line fsx.exe. While I run the following script lines from VS2012 interactive window there was no problem to open all the namespaces. #r "FSharp.Core.dll" #r "System.Data.dll" #r "FSharp.Data.TypeProviders.dll" #r "System.Data.Linq.dll" open Microsoft.FSharp.Linq open System open System.Data open System.Data

F#/C# - fsx Script Files and Project References

主宰稳场 提交于 2019-12-12 17:44:59
问题 You have a solution with one C# project in it. SomeComp.Framework is the name. You add a F# project to the solution. You reference the SomeComp.Framework project in the F# project. You insert a script file - test.fsx into the F# project. What is the correct way to reference the C# assembly in the script file? #r "SomeComp.Framework.dll" // doesn't work Is there some way to do this without hardcoding a path? Does the .fsx file get any settings/properties from being located inside a F# project?

How to change F# Interactive newline character

℡╲_俬逩灬. 提交于 2019-12-12 09:53:46
问题 In a .fs file a newline is denoted by \r\n , but in the F# Interactive window it is \n . In a problem I'm currently trying to solve, the length of a multiple line literal string matters. So a problem arises when I am testing code in the F# Interactive window, because the length of the string is different from in normal execution. I hope there is an option to change the newline 'character' in F# Interactive to \r\n , but I can't find it. Does anyone know where I can achieve this, or some other

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

ServiceModel and f#

早过忘川 提交于 2019-12-11 09:47:03
问题 I am just starting with f# so the question may seem easy for some of you. so, I am trying to use SyndicationFeed which is located in System.ServiceModel.Syndication namespace. I added following references: System.ServiceModel and System.ServiceModel.Web to the project. The result is that it builds successfully, but when I switch to "F# interactive" window I got an error which reads "error FS0039: The namespace 'ServiceModel' is not defined". I goggled that I should also add reference to

Int Option instead of Int in F#

我的梦境 提交于 2019-12-11 05:59:56
问题 I am having trouble with the following: let safeDiv x y = match (x,y) with | (_, Some 0) -> None | (Some xx, Some yy) -> Some (xx/yy) | _ -> None When I go to run this simple function in the interactive window of Visual Studio like so: safeDiv 4 2 I get the following error... This expression was expected to have type int option but here has type int. Could it be I'm meant to use safeDiv Some(4) Some(2) ? This doesn't work either... 回答1: Ok, this is overkill but I actually did something