F#是一种功能编程语言,在F#中,函数的工作方式类似于数据类型,您可以像其他任何变量一样声明和使用函数。
以下代码显示了一个简单的F#程序-
open System (* This is a multi-line comment *) //This is a single-line comment let sign num = if num > 0 then "positive" elif num < 0 then "negative" else "zero" let main() = Console.WriteLine("sign 5: {0}", (sign 5)) main()
编译并执行程序时,将产生以下输出-
sign 5: positive
请注意-
链接:https://www.learnfk.comhttps://www.learnfk.com/fsharp/fsharp-program-structure.html
来源:LearnFk无涯教程网
F#代码文件可能以许多 open 语句开头。
文件的主体包括实现应用程序业务逻辑的其他功能。
主循环包含最上面的可执行语句。
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)