在F#interactive中,如何查看此会话中定义的变量/函数列表?像whos()python或ls()R中的函数一样?谢谢.
我使用F#作为FSI的脚本语言.有没有办法在我的脚本中包含另一个fsx文件?我希望能够将我的脚本分成多个文件以执行更大的任务.
谢谢.
我知道我可以下载"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中.这有可再分发的吗?
我在我的构建工具(" FAKE - F#Make ")中托管FSI.exe,我需要从我的fsx脚本中设置FSI.exe的ExitCode.这可能吗?
目前我在F#构建脚本中引发错误,这会设置退出代码,但它也会在构建日志中显示讨厌的异常和stackstraces.
谢谢,提前和最诚挚的问候,Steffen
我有这个简单代码(一个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)
因此我有两个问题:
我的计算机上有8 GB内存,根据我的计算,10 000*10 000矩阵应该占用381 MB [以这种方式计算:10 000 * 10 000 = 100 000 000矩阵中的整数=> 100 000 …
我编写了这段代码,它在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?
这是场景:
E:\<directories>\fsharp-tapl\arith从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)鉴于代码:
#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?
我尝试通过批处理文件使用 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#完成一个项目.我对函数式编程很陌生,虽然我熟悉列表项不可变的想法,但我仍然遇到一些问题:
我有一个格式的字符串列表
["(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)
我已经找到了无数种方法来连接列表元素,到目前为止我的最佳猜测(展开,或类似的东西)都没有结果.任何帮助或正确方向的一点将非常感激.谢谢!