f#-scripting

How does fsi.ShowDeclarationValues work?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 04:10:09
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. Daniel is correct - this disables just printing of the values and not the declarations themselves. One situation where this is useful is when

F# for scripting: location of script file

不想你离开。 提交于 2019-11-30 05:48:15
In an F# script file (.fsx), how can I determine the location of the .fsx file currently executing? I'd like to resolve paths relative to it. I tried Assembly.GetExecutingAssembly().CodeBase but that doesn't work in a "dynamic assembly", apparently. extract from F# spec: _ _SOURCE_DIRECTORY__ - Replaced by a literal verbatim string that specifies the name of the directory that contains the current file, for example, C:\source. The name of the current file is determined by the most recent line directive in the file. If no line directive has been given, the name is determined by that given to

F# for scripting: location of script file

给你一囗甜甜゛ 提交于 2019-11-29 04:56:24
问题 In an F# script file (.fsx), how can I determine the location of the .fsx file currently executing? I'd like to resolve paths relative to it. I tried Assembly.GetExecutingAssembly().CodeBase but that doesn't work in a "dynamic assembly", apparently. 回答1: extract from F# spec: _ _SOURCE_DIRECTORY__ - Replaced by a literal verbatim string that specifies the name of the directory that contains the current file, for example, C:\source. The name of the current file is determined by the most recent

Merge two lists

坚强是说给别人听的谎言 提交于 2019-11-28 11:09:10
I am looking to merge 2 lists in F# in a purely functional way. I am having a hard time understanding the syntax. Let say I have a tuple ([5;3;8],[2;9;4]) When I call the function, it should return [5;2;3;9;8;4] Here is why I have so far, which is wrong I am sure. If someone could explain it in a simple way I would be grateful. let rec interleave (xs,ys) = function |([], ys) -> ys |(x::xs, y::ys) -> x :: y:: interleave (xs,ys) Your function is almost right. let f = function is shorthand for let f x = match x with so you don't need explicit args. Also, your algorithm needs some tweaking. let

Merge two lists

泪湿孤枕 提交于 2019-11-27 06:04:14
问题 I am looking to merge 2 lists in F# in a purely functional way. I am having a hard time understanding the syntax. Let say I have a tuple ([5;3;8],[2;9;4]) When I call the function, it should return [5;2;3;9;8;4] Here is why I have so far, which is wrong I am sure. If someone could explain it in a simple way I would be grateful. let rec interleave (xs,ys) = function |([], ys) -> ys |(x::xs, y::ys) -> x :: y:: interleave (xs,ys) 回答1: Your function is almost right. let f = function is shorthand