Skip to content

Commit 3953ede

Browse files
committed
update
1 parent d67e264 commit 3953ede

File tree

16 files changed

+581
-8
lines changed

16 files changed

+581
-8
lines changed

.vscode/launch.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": []
7+
}

FPStarter.sln

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HighAndPure.Cs", "Lesson\Hi
2222
EndProject
2323
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "HighAndPure.Fs", "Lesson\HighAndPure.Fs\HighAndPure.Fs.fsproj", "{6E9FF4A7-3840-43DD-A456-A5C4D7D7898C}"
2424
EndProject
25+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "HighAddPure.Fs.Video", "Lesson\HighAddPure.Fs.Video\HighAddPure.Fs.Video.fsproj", "{9D8FF37E-653B-4550-A60D-4D8F1441FC88}"
26+
EndProject
27+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HighAddPure.Cs.Video", "Lesson\HighAddPure.Cs.Video\HighAddPure.Cs.Video.csproj", "{3D7E4BFB-7C66-4543-97BD-E83A8D0D0BA5}"
28+
EndProject
29+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "2. 函数签名与诚实的函数", "2. 函数签名与诚实的函数", "{62001ED1-B2D2-457E-A893-F1AA9D7E31ED}"
30+
EndProject
31+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FuncSign.Cs", "Lesson\FuncSign.Cs\FuncSign.Cs.csproj", "{D8C3D428-0480-492C-A066-14375DB3C097}"
32+
EndProject
33+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FuncSign.Fs", "Lesson\FuncSign.Fs\FuncSign.Fs.fsproj", "{C9D2086F-032C-4483-92C1-BF5C50A206AA}"
34+
EndProject
35+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FuncSign.Cs.Video", "Lesson\FuncSign.Cs.Video\FuncSign.Cs.Video.csproj", "{95BB4313-8CE7-4AA7-B099-0A1017522BA4}"
36+
EndProject
37+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FuncSign.Fs.Video", "Lesson\FuncSign.Fs.Video\FuncSign.Fs.Video.fsproj", "{C7E702CA-822F-4B6D-A82C-9EE76F6D8CFC}"
38+
EndProject
2539
Global
2640
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2741
Debug|Any CPU = Debug|Any CPU
@@ -60,6 +74,30 @@ Global
6074
{6E9FF4A7-3840-43DD-A456-A5C4D7D7898C}.Debug|Any CPU.Build.0 = Debug|Any CPU
6175
{6E9FF4A7-3840-43DD-A456-A5C4D7D7898C}.Release|Any CPU.ActiveCfg = Release|Any CPU
6276
{6E9FF4A7-3840-43DD-A456-A5C4D7D7898C}.Release|Any CPU.Build.0 = Release|Any CPU
77+
{9D8FF37E-653B-4550-A60D-4D8F1441FC88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
78+
{9D8FF37E-653B-4550-A60D-4D8F1441FC88}.Debug|Any CPU.Build.0 = Debug|Any CPU
79+
{9D8FF37E-653B-4550-A60D-4D8F1441FC88}.Release|Any CPU.ActiveCfg = Release|Any CPU
80+
{9D8FF37E-653B-4550-A60D-4D8F1441FC88}.Release|Any CPU.Build.0 = Release|Any CPU
81+
{3D7E4BFB-7C66-4543-97BD-E83A8D0D0BA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
82+
{3D7E4BFB-7C66-4543-97BD-E83A8D0D0BA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
83+
{3D7E4BFB-7C66-4543-97BD-E83A8D0D0BA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
84+
{3D7E4BFB-7C66-4543-97BD-E83A8D0D0BA5}.Release|Any CPU.Build.0 = Release|Any CPU
85+
{D8C3D428-0480-492C-A066-14375DB3C097}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
86+
{D8C3D428-0480-492C-A066-14375DB3C097}.Debug|Any CPU.Build.0 = Debug|Any CPU
87+
{D8C3D428-0480-492C-A066-14375DB3C097}.Release|Any CPU.ActiveCfg = Release|Any CPU
88+
{D8C3D428-0480-492C-A066-14375DB3C097}.Release|Any CPU.Build.0 = Release|Any CPU
89+
{C9D2086F-032C-4483-92C1-BF5C50A206AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
90+
{C9D2086F-032C-4483-92C1-BF5C50A206AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
91+
{C9D2086F-032C-4483-92C1-BF5C50A206AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
92+
{C9D2086F-032C-4483-92C1-BF5C50A206AA}.Release|Any CPU.Build.0 = Release|Any CPU
93+
{95BB4313-8CE7-4AA7-B099-0A1017522BA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
94+
{95BB4313-8CE7-4AA7-B099-0A1017522BA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
95+
{95BB4313-8CE7-4AA7-B099-0A1017522BA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
96+
{95BB4313-8CE7-4AA7-B099-0A1017522BA4}.Release|Any CPU.Build.0 = Release|Any CPU
97+
{C7E702CA-822F-4B6D-A82C-9EE76F6D8CFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
98+
{C7E702CA-822F-4B6D-A82C-9EE76F6D8CFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
99+
{C7E702CA-822F-4B6D-A82C-9EE76F6D8CFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
100+
{C7E702CA-822F-4B6D-A82C-9EE76F6D8CFC}.Release|Any CPU.Build.0 = Release|Any CPU
63101
EndGlobalSection
64102
GlobalSection(NestedProjects) = preSolution
65103
{40E7AF00-267E-482F-AFDD-3CF5FA4690F2} = {8BBCB50B-1C47-429C-B0FF-7926FC5014F2}
@@ -68,5 +106,12 @@ Global
68106
{8BE7A355-F10E-4387-9158-190415AFF9CC} = {8BBCB50B-1C47-429C-B0FF-7926FC5014F2}
69107
{3AEA926D-5D05-4781-AA0F-FDF7A936D16B} = {8BE7A355-F10E-4387-9158-190415AFF9CC}
70108
{6E9FF4A7-3840-43DD-A456-A5C4D7D7898C} = {8BE7A355-F10E-4387-9158-190415AFF9CC}
109+
{9D8FF37E-653B-4550-A60D-4D8F1441FC88} = {8BE7A355-F10E-4387-9158-190415AFF9CC}
110+
{3D7E4BFB-7C66-4543-97BD-E83A8D0D0BA5} = {8BE7A355-F10E-4387-9158-190415AFF9CC}
111+
{62001ED1-B2D2-457E-A893-F1AA9D7E31ED} = {8BBCB50B-1C47-429C-B0FF-7926FC5014F2}
112+
{D8C3D428-0480-492C-A066-14375DB3C097} = {62001ED1-B2D2-457E-A893-F1AA9D7E31ED}
113+
{C9D2086F-032C-4483-92C1-BF5C50A206AA} = {62001ED1-B2D2-457E-A893-F1AA9D7E31ED}
114+
{95BB4313-8CE7-4AA7-B099-0A1017522BA4} = {62001ED1-B2D2-457E-A893-F1AA9D7E31ED}
115+
{C7E702CA-822F-4B6D-A82C-9EE76F6D8CFC} = {62001ED1-B2D2-457E-A893-F1AA9D7E31ED}
71116
EndGlobalSection
72117
EndGlobal
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
</Project>

Lesson/FuncSign.Cs.Video/Program.cs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// See https://aka.ms/new-console-template for more information
2+
3+
Console.WriteLine("Hello, World!");
4+
5+
Func<string> f1 = () => "Hello, World!";
6+
7+
int AddOne(int a) => a + 1; // int -> int unit ()
8+
9+
var f2 = () => Console.WriteLine("Hello, World!"); // unit -> unit
10+
11+
// int -> bool
12+
// PlayerLv -> bool
13+
14+
//Where Filter: (IEnumerable<T>, (T -> bool)) -> IEnumerable<T>
15+
16+
var f3 = (int a, int b) => a + b; // (int, int) -> int
17+
18+
// Age: int
19+
// 121 * 2 = 242
20+
bool IsAgeYoung(PersonData personData)
21+
{
22+
return personData.Age.Value <= 24;
23+
} // Age -> bool
24+
25+
26+
27+
28+
// () -> string () => "Hello, World!";
29+
// () -> int () => 42;
30+
// (int, int) -> int (int a, int b) => a + b;
31+
// string -> int (string s) => s.Length;
32+
// int -> bool (int x) => x % 2 == 0;
33+
// () -> () () => Console.WriteLine("Hello, World!");
34+
35+
36+
Func<int, int, bool> SwapArgs(Func<int, int, bool> func)
37+
{
38+
return (a, b) => func(b, a);
39+
}
40+
41+
public class Age {
42+
public int Value { get; }
43+
public Age(int value) {
44+
if (value < 0 || value > 120)
45+
throw new ArgumentException("Age must be between 0 and 120");
46+
Value = value;
47+
}
48+
}
49+
public enum Gender
50+
{
51+
Female,
52+
Male
53+
}
54+
55+
public class PersonData
56+
{
57+
public Age Age { get; set; } = null;
58+
public Gender Gender { get; set; }
59+
}
60+
61+
62+
// ((int, int) -> bool) -> ((int, int) -> bool)
63+
// ((a, b) -> c) -> ((b, a) -> c)
64+

Lesson/FuncSign.Cs/FuncSign.Cs.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
</Project>

Lesson/FuncSign.Cs/Program.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// See https://aka.ms/new-console-template for more information
2+
int AddOne(int a) => a + 1;
3+
4+
5+
var f1 = () => "Hello, World!";
6+
var f2 = () => 42;
7+
var f3 = (int a, int b) => a + b;
8+
var f4 = (string s) => s.Length;
9+
var f5 = (int x) => x % 2 == 0;
10+
var f6 = () => Console.WriteLine("Hello, World!");
11+
12+
bool IsAgeYoung(int age)
13+
{
14+
if (age < 0 || age > 120)
15+
{
16+
throw new ArgumentException("Age must be between 0 and 120");
17+
}
18+
return age <= 24;
19+
}
20+
21+
bool IsAgeYoung1(Age age) => age.Value <= 24;
22+
23+
24+
public class Age
25+
{
26+
public int Value { get; }
27+
28+
public Age(int value)
29+
{
30+
if (value < 0 || value > 120)
31+
throw new ArgumentException("Age must be between 0 and 120");
32+
Value = value;
33+
}
34+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<Compile Include="Program.fs"/>
10+
</ItemGroup>
11+
12+
</Project>

Lesson/FuncSign.Fs.Video/Program.fs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// For more information see https://aka.ms/fsharp-console-apps
2+
3+
let f1() = "Hello World"
4+
let f2() = 1
5+
let f3 a b = a + b
6+
// let f7(a, b) = a + b
7+
let f4 (s:string) = s.Length
8+
let f5 d = d % 2 = 0
9+
let f6() = printfn "Hello World"

Lesson/FuncSign.Fs/FuncSign.Fs.fsproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<Compile Include="Program.fs"/>
10+
</ItemGroup>
11+
12+
</Project>

Lesson/FuncSign.Fs/Program.fs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// For more information see https://aka.ms/fsharp-console-apps
2+
let addOne a = a + 1
3+
4+
let f1() = "Hello World"
5+
let f2() = 1
6+
let f3 a b = a + b
7+
// let f3(a, b) = a + b 虽然这种才是
8+
let f4 (s:string) = s.Length
9+
let f5 d = d % 2 = 0
10+
let f6() = printfn "Hello World"
11+

0 commit comments

Comments
 (0)