标签: f#-interactive

F#interactive - 如何查看当前会话中定义的所有变量

在F#interactive中,如何查看此会话中定义的变量/函数列表?像whos()python或ls()R中的函数一样?谢谢.

f# f#-interactive

10
推荐指数
2
解决办法
2111
查看次数

在FSX文件中包含文件?

我使用F#作为FSI的脚本语言.有没有办法在我的脚本中包含另一个fsx文件?我希望能够将我的脚本分成多个文件以执行更大的任务.

谢谢.

f# f#-interactive f#-scripting

10
推荐指数
1
解决办法
4408
查看次数

我在哪里可以获得F#编译器和FSI v4.0?

我知道我可以下载"April CTP"来获得.NET 2.0的F#2.0.但我需要FSC和F#Interactive for .NET 4.0.在安装了VS 2010的计算机上,它最终位于C:\ Program Files(x86)\ Microsoft F#\ v4.0中.这有可再分发的吗?

f# f#-interactive

9
推荐指数
2
解决办法
6098
查看次数

在自托管的F#脚本中设置ExitCode

我在我的构建工具(" FAKE - F#Make ")中托管FSI.exe,我需要从我的fsx脚本中设置FSI.exe的ExitCode.这可能吗?

目前我在F#构建脚本中引发错误,这会设置退出代码,但它也会在构建日志中显示讨厌的异常和stackstraces.

谢谢,提前和最诚挚的问候,Steffen

f# f#-interactive f#-scripting

9
推荐指数
1
解决办法
611
查看次数

矩阵的内存不足异常

我有这个简单代码(一个10 000*10 000矩阵)的"System.OutOfMemoryException"异常乘以它自己:

#time

#r "Microsoft.Office.Interop.Excel"
#r "FSharp.PowerPack.dll"

open System
open System.IO

open Microsoft.FSharp.Math
open System.Collections.Generic


let mutable Matrix1 = Matrix.create 10000 10000 0.

let matrix4 = Matrix1 * Matrix1
Run Code Online (Sandbox Code Playgroud)

我有以下错误:

System.OutOfMemoryException: An exception 'System.OutOfMemoryException' has been raised
   Microsoft.FSharp.Collections.Array2DModule.ZeroCreate[T](Int32 length1, Int32 length2)
   Microsoft.FSharp.Math.DoubleImpl.mulDenseMatrixDS(DenseMatrix`1 a, DenseMatrix`1 b)
   Microsoft.FSharp.Math.SpecializedGenericImpl.mulM[a](Matrix`1 a, Matrix`1 b)
   <StartupCode$FSI_0004>.$FSI_0004.main@() dans C:\Users\XXXXXXX\documents\visual studio 2010\Projects\Library1\Library1\Module1.fs:line 92
Stop due to an error
Run Code Online (Sandbox Code Playgroud)

因此我有两个问题:

  1. 我的计算机上有8 GB内存,根据我的计算,10 000*10 000矩阵应该占用381 MB [以这种方式计算:10 000 * 10 000 = 100 000 000矩阵中的整数=> 100 000 …

f# matrix out-of-memory f#-interactive

9
推荐指数
2
解决办法
1024
查看次数

定义模块VS.NET与F#Interactive

我编写了这段代码,它在VS.NET 2010中编译并完美地运行

module ConfigHandler
open System
open System.Xml
open System.Configuration

let GetConnectionString (key : string) =
  ConfigurationManager.ConnectionStrings.Item(key).ConnectionString
Run Code Online (Sandbox Code Playgroud)

但是,当我执行控制+ A和Alt + Enter将其发送到FSI时,我收到错误

ConfigHandler.fs(2,1):错误FS0010:定义中结构化构造的意外启动.预期'='或其他令牌.

好.

所以我将我的代码更改为

module ConfigHandler =
  open System
  open System.Xml
  open System.Configuration

  let GetConnectionString (key : string) =
    ConfigurationManager.ConnectionStrings.Item(key).ConnectionString
Run Code Online (Sandbox Code Playgroud)

现在Control + A,Alt + Enter成功了,我很好地告诉我FSI

module ConfigHandler = begin val GetConnectionString:string - > string end

但是现在如果我尝试在VS.NET 2010中编译我的代码,我会收到一条错误消息

库或多文件应用程序中的文件必须以命名空间或模块声明开头,例如'namespace SomeNamespace.SubNamespace'或'module SomeNamespace.SomeModule'

我怎么能两个都有?能否在VS.NET中编译并能够将模块发送到FSI?

f# f#-interactive

9
推荐指数
2
解决办法
2215
查看次数

F#Interactive #I命令如何了解项目路径?

这是场景:

  1. 打开Visual Studio.这是在VS2010 Pro中完成的.
  2. 在Visual Studio中打开F#Interactive
  3. 使用fsx文件打开项目
    注意:Project和fsx文件位于E:\<directories>\fsharp-tapl\arith
  4. 从fsx文件向F#Interactive发送命令

    > System.Environment.CurrentDirectory;; 
    val it : string = "C:\Users\Eric\AppData\Local\Temp"
    
    Run Code Online (Sandbox Code Playgroud)

    我没想到Temp目录,但它有意义.

    > #r @"arith.exe"
    Examples.fsx(7,1): error FS0082: Could not resolve this reference. 
    Could not locate the assembly "arith.exe". 
    Check to make sure the assembly exists on disk. 
    If this reference is required by your code, you may get compilation errors. 
    (Code=MSB3245)
    
    Examples.fsx(7,1): error FS0084: Assembly reference 'arith.exe' was not found 
    or is invalid
    
    Run Code Online (Sandbox Code Playgroud)

    #r命令错误显示F#Interactive当前不知道arith.exe的位置.

    > #I @"bin\Debug"
    --> Added 'E:\<directories>\fsharp-tapl\arith\bin\Debug' 
    to library …
    Run Code Online (Sandbox Code Playgroud)

f# visual-studio f#-interactive

9
推荐指数
1
解决办法
4447
查看次数

JsonProvider"这不是常量表达式或有效的自定义属性值"

鉴于代码:

#if INTERACTIVE
#r "bin\Debug\FSharp.Data.dll"

#endif

open System
open FSharp.Data
open FSharp.Data.Json

let testJson = """{ "workingDir":"hello", "exportDir":"hi there", "items":[{ "source":"", "dest":"", "args": {"name":"that"} }] }"""

//here is where i get the error
let Schema = JsonProvider<testJson>
Run Code Online (Sandbox Code Playgroud)

最后一行不断给出错误"这不是一个常量表达式或有效的自定义属性值" - 这是什么意思?我怎样才能读到这个JSON?

f# f#-interactive type-providers f#-data

9
推荐指数
1
解决办法
1670
查看次数

带参数运行 f# 脚本

我尝试通过批处理文件使用 fsi.exe 运行 f# 脚本

CALL "path\fsi.exe" --quiet --exec --use:"path\FindAndDelete.fsx" arg1 arg2 arg3
Run Code Online (Sandbox Code Playgroud)

我需要我的脚本程序与 arg1 arg2 和 arg3 一起运行。但是命令:

for arg in Environment.GetCommandLineArgs() do
    printfn "%s" arg
Run Code Online (Sandbox Code Playgroud)

打印所有参数并说 arg1 是错误参数,但我只需要在脚本中使用 arg1、arg2、arg3 进行操作。尽管运行带有参数的 f# 脚本并使用它们进行操作的最佳方法是什么?

f#-interactive fsi

9
推荐指数
1
解决办法
2027
查看次数

如何操作F#中的列表元素

我目前正在使用F#完成一个项目.我对函数式编程很陌生,虽然我熟悉列表项不可变的想法,但我仍然遇到一些问题:

我有一个格式的字符串列表

["(states, (1,2,3,4,5))"; "(alpha, (1,2))"; "(final, (1))"]
Run Code Online (Sandbox Code Playgroud)

我想要做的是将每个列表元素转换为自己的列表,而不使用最初的逗号分隔字符串.输出应该如下所示:

["1"; "2"; "3"; "4"; "5"]
["1"; "2"]
["1"]
Run Code Online (Sandbox Code Playgroud)

我已经找到了无数种方法来连接列表元素,到目前为止我的最佳猜测(展开,或类似的东西)都没有结果.任何帮助或正确方向的一点将非常感激.谢谢!

f# functional-programming f#-interactive f#-3.0

9
推荐指数
3
解决办法
641
查看次数