新增内容
This commit is contained in:
parent
0678bbad9a
commit
05bde0f1e7
|
@ -7,7 +7,9 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.fs" />
|
||||
<Compile Include="HelloWorld.fs" />
|
||||
<Compile Include="LetBinding.fs" />
|
||||
<Compile Include="SimpleFunction.fs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
module HelloWorld
|
||||
|
||||
// F#中基本部分均为函数,并且使用模块来组织各部分函数
|
||||
|
||||
// 定义一个名为main的函数
|
||||
let main () =
|
||||
// F#向控制台输出Hello world from F#字符
|
||||
printfn "Hello world from F#"
|
||||
|
||||
// 调用该函数
|
||||
main ()
|
||||
|
||||
// 值得一提,F#的入口函数并不是main函数,并且它是隐式的,您并不需要显式说明
|
||||
// 项目中执行文件最后处即为入口点
|
|
@ -0,0 +1,23 @@
|
|||
module LetBinding
|
||||
|
||||
// 在F#中创建变量使用let关键字
|
||||
// 作用是将值绑定到名称上
|
||||
let a = 1
|
||||
// 将值为1的a输出
|
||||
printfn "%d" a
|
||||
|
||||
// 变量默认是不可变的
|
||||
// 函数式秉持着这样一种观念:人不能两次踏入同一条河流
|
||||
// 所以下面的表达式是非法的
|
||||
// a = 2
|
||||
|
||||
// 类型是对现实世界抽象化的表述,它表达了事物的边界
|
||||
// 对于F#来说,类型也是至关重要的
|
||||
// 上面let a = 1并没有说明类型
|
||||
// 但是我们的变量在构建的时候已经确定了类型
|
||||
// 这里使用了类型推导技术,变量的类型由右侧的表达式决定
|
||||
|
||||
// 在F#中拥有一些基本类型
|
||||
// 比如1默认是int类型, 1.0默认是float类型,'a'默认是char类型,"abc"是string类型
|
||||
// 下面的b将会被编译器推导为float类型
|
||||
let b = 3.1415926
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
|
||||
// For more information see https://aka.ms/fsharp-console-apps
|
||||
printfn "Hello from F#"
|
|
@ -0,0 +1,21 @@
|
|||
module SimpleFunction
|
||||
|
||||
// F#中的函数与数学概念上的函数类似
|
||||
// 此数函彼数,是一个集合与另一个集合的映射
|
||||
|
||||
// let绑定也可将函数绑定到名称上,以此构建一个函数
|
||||
// 当然,F#的函数一个值,与其他值并没有什么不同,所谓第一类函数
|
||||
|
||||
let a = 1
|
||||
|
||||
// 下面函数将一个a输入,并且返回a + 1
|
||||
let add_one a = a + 1
|
||||
|
||||
// 我们尝试将该函数的结果打印出来
|
||||
printfn "%d" (add_one a)
|
||||
|
||||
// 该函数将输出2(即a + 1)
|
||||
|
||||
// 我们也可以实现多个参数的函数
|
||||
let add a b = a + b
|
||||
let mul a b = a * b
|
Binary file not shown.
|
@ -0,0 +1,82 @@
|
|||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v6.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v6.0": {
|
||||
"Basic-practice-of-FSharp/1.0.0": {
|
||||
"dependencies": {
|
||||
"FSharp.Core": "6.0.1"
|
||||
},
|
||||
"runtime": {
|
||||
"Basic-practice-of-FSharp.dll": {}
|
||||
}
|
||||
},
|
||||
"FSharp.Core/6.0.1": {
|
||||
"runtime": {
|
||||
"lib/netstandard2.1/FSharp.Core.dll": {
|
||||
"assemblyVersion": "6.0.0.0",
|
||||
"fileVersion": "6.0.121.52202"
|
||||
}
|
||||
},
|
||||
"resources": {
|
||||
"lib/netstandard2.1/cs/FSharp.Core.resources.dll": {
|
||||
"locale": "cs"
|
||||
},
|
||||
"lib/netstandard2.1/de/FSharp.Core.resources.dll": {
|
||||
"locale": "de"
|
||||
},
|
||||
"lib/netstandard2.1/es/FSharp.Core.resources.dll": {
|
||||
"locale": "es"
|
||||
},
|
||||
"lib/netstandard2.1/fr/FSharp.Core.resources.dll": {
|
||||
"locale": "fr"
|
||||
},
|
||||
"lib/netstandard2.1/it/FSharp.Core.resources.dll": {
|
||||
"locale": "it"
|
||||
},
|
||||
"lib/netstandard2.1/ja/FSharp.Core.resources.dll": {
|
||||
"locale": "ja"
|
||||
},
|
||||
"lib/netstandard2.1/ko/FSharp.Core.resources.dll": {
|
||||
"locale": "ko"
|
||||
},
|
||||
"lib/netstandard2.1/pl/FSharp.Core.resources.dll": {
|
||||
"locale": "pl"
|
||||
},
|
||||
"lib/netstandard2.1/pt-BR/FSharp.Core.resources.dll": {
|
||||
"locale": "pt-BR"
|
||||
},
|
||||
"lib/netstandard2.1/ru/FSharp.Core.resources.dll": {
|
||||
"locale": "ru"
|
||||
},
|
||||
"lib/netstandard2.1/tr/FSharp.Core.resources.dll": {
|
||||
"locale": "tr"
|
||||
},
|
||||
"lib/netstandard2.1/zh-Hans/FSharp.Core.resources.dll": {
|
||||
"locale": "zh-Hans"
|
||||
},
|
||||
"lib/netstandard2.1/zh-Hant/FSharp.Core.resources.dll": {
|
||||
"locale": "zh-Hant"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"Basic-practice-of-FSharp/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
},
|
||||
"FSharp.Core/6.0.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-VrFAiW8dEEekk+0aqlbvMNZzDvYXmgWZwAt68AUBqaWK8RnoEVUNglj66bZzhs4/U63q0EfXlhcEKnH1sTYLjw==",
|
||||
"path": "fsharp.core/6.0.1",
|
||||
"hashPath": "fsharp.core.6.0.1.nupkg.sha512"
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net6.0",
|
||||
"framework": {
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "6.0.0"
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
namespace Microsoft.BuildSettings
|
||||
[<System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName="")>]
|
||||
do ()
|
|
@ -0,0 +1,17 @@
|
|||
// <auto-generated>
|
||||
// Generated by the FSharp WriteCodeFragment class.
|
||||
// </auto-generated>
|
||||
namespace FSharp
|
||||
|
||||
open System
|
||||
open System.Reflection
|
||||
|
||||
|
||||
[<assembly: System.Reflection.AssemblyCompanyAttribute("Basic-practice-of-FSharp")>]
|
||||
[<assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")>]
|
||||
[<assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")>]
|
||||
[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")>]
|
||||
[<assembly: System.Reflection.AssemblyProductAttribute("Basic-practice-of-FSharp")>]
|
||||
[<assembly: System.Reflection.AssemblyTitleAttribute("Basic-practice-of-FSharp")>]
|
||||
[<assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")>]
|
||||
do()
|
|
@ -0,0 +1 @@
|
|||
6222a14c3308d0fc0d25ec1d195e485c25706689
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,26 @@
|
|||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/obj/Debug/net6.0/Basic-practice-of-FSharp.AssemblyInfoInputs.cache
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/obj/Debug/net6.0/Basic-practice-of-FSharp.AssemblyInfo.fs
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/obj/Debug/net6.0/Basic-practice-of-FSharp.fsproj.AssemblyReference.cache
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/bin/Debug/net6.0/Basic-practice-of-FSharp
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/bin/Debug/net6.0/Basic-practice-of-FSharp.deps.json
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/bin/Debug/net6.0/Basic-practice-of-FSharp.runtimeconfig.json
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/bin/Debug/net6.0/Basic-practice-of-FSharp.dll
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/bin/Debug/net6.0/Basic-practice-of-FSharp.pdb
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/bin/Debug/net6.0/FSharp.Core.dll
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/bin/Debug/net6.0/cs/FSharp.Core.resources.dll
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/bin/Debug/net6.0/de/FSharp.Core.resources.dll
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/bin/Debug/net6.0/es/FSharp.Core.resources.dll
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/bin/Debug/net6.0/fr/FSharp.Core.resources.dll
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/bin/Debug/net6.0/it/FSharp.Core.resources.dll
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/bin/Debug/net6.0/ja/FSharp.Core.resources.dll
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/bin/Debug/net6.0/ko/FSharp.Core.resources.dll
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/bin/Debug/net6.0/pl/FSharp.Core.resources.dll
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/bin/Debug/net6.0/pt-BR/FSharp.Core.resources.dll
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/bin/Debug/net6.0/ru/FSharp.Core.resources.dll
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/bin/Debug/net6.0/tr/FSharp.Core.resources.dll
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/bin/Debug/net6.0/zh-Hans/FSharp.Core.resources.dll
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/bin/Debug/net6.0/zh-Hant/FSharp.Core.resources.dll
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/obj/Debug/net6.0/Basic-practice-of-FSharp.fsproj.CopyComplete
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/obj/Debug/net6.0/Basic-practice-of-FSharp.dll
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/obj/Debug/net6.0/Basic-practice-of-FSharp.pdb
|
||||
/home/sanchime/桌面/Program/F#/Basic-practice-of-FSharp/Basic-practice-of-FSharp/obj/Debug/net6.0/Basic-practice-of-FSharp.genruntimeconfig.cache
|
|
@ -0,0 +1 @@
|
|||
7cf80e63319ef6c9b32b4cc667a5dad8fccb8d4d
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,2 @@
|
|||
2022/2/16 下午1:17:11
|
||||
{}
|
Loading…
Reference in New Issue