From f26caf2cdc483ef3ebe33855c6c74fc456fbdbda Mon Sep 17 00:00:00 2001 From: MikePuzanov Date: Tue, 29 Mar 2022 00:19:44 +0300 Subject: [PATCH 1/3] add task with test --- .../Point-free.Test/Point-free.Test.fsproj | 29 +++++++++++++++++++ Point-free/Point-free.Test/Point-freeTest.fs | 13 +++++++++ Point-free/Point-free.Test/Program.fs | 4 +++ Point-free/Point-free.sln | 22 ++++++++++++++ Point-free/Point-free/Point-free.fsproj | 14 +++++++++ Point-free/Point-free/Program.fs | 12 ++++++++ 6 files changed, 94 insertions(+) create mode 100644 Point-free/Point-free.Test/Point-free.Test.fsproj create mode 100644 Point-free/Point-free.Test/Point-freeTest.fs create mode 100644 Point-free/Point-free.Test/Program.fs create mode 100644 Point-free/Point-free.sln create mode 100644 Point-free/Point-free/Point-free.fsproj create mode 100644 Point-free/Point-free/Program.fs diff --git a/Point-free/Point-free.Test/Point-free.Test.fsproj b/Point-free/Point-free.Test/Point-free.Test.fsproj new file mode 100644 index 0000000..a477fbc --- /dev/null +++ b/Point-free/Point-free.Test/Point-free.Test.fsproj @@ -0,0 +1,29 @@ + + + + net6.0 + Point_free.Test + + false + false + + + + + + + + + + + + + + + + + + + + + diff --git a/Point-free/Point-free.Test/Point-freeTest.fs b/Point-free/Point-free.Test/Point-freeTest.fs new file mode 100644 index 0000000..c779a7b --- /dev/null +++ b/Point-free/Point-free.Test/Point-freeTest.fs @@ -0,0 +1,13 @@ +module Point_free.Test + +open NUnit.Framework +open FsCheck +open Program + +[] +let checkEqualTest () = + let check x l = + funcToList x l = funcToList'3 () x l + + + Check.QuickThrowOnFailure check \ No newline at end of file diff --git a/Point-free/Point-free.Test/Program.fs b/Point-free/Point-free.Test/Program.fs new file mode 100644 index 0000000..176a7b6 --- /dev/null +++ b/Point-free/Point-free.Test/Program.fs @@ -0,0 +1,4 @@ +module Program = + + [] + let main _ = 0 diff --git a/Point-free/Point-free.sln b/Point-free/Point-free.sln new file mode 100644 index 0000000..5c50ef4 --- /dev/null +++ b/Point-free/Point-free.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Point-free", "Point-free\Point-free.fsproj", "{5F3A9B01-2E6F-435A-988E-D3E4E3046478}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Point-free.Test", "Point-free.Test\Point-free.Test.fsproj", "{AEBF63D5-AB31-416B-9E94-2B90E22D1A67}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5F3A9B01-2E6F-435A-988E-D3E4E3046478}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5F3A9B01-2E6F-435A-988E-D3E4E3046478}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5F3A9B01-2E6F-435A-988E-D3E4E3046478}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5F3A9B01-2E6F-435A-988E-D3E4E3046478}.Release|Any CPU.Build.0 = Release|Any CPU + {AEBF63D5-AB31-416B-9E94-2B90E22D1A67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AEBF63D5-AB31-416B-9E94-2B90E22D1A67}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AEBF63D5-AB31-416B-9E94-2B90E22D1A67}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AEBF63D5-AB31-416B-9E94-2B90E22D1A67}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Point-free/Point-free/Point-free.fsproj b/Point-free/Point-free/Point-free.fsproj new file mode 100644 index 0000000..2cc950a --- /dev/null +++ b/Point-free/Point-free/Point-free.fsproj @@ -0,0 +1,14 @@ + + + + Exe + net6.0 + Point_free + Windows + + + + + + + diff --git a/Point-free/Point-free/Program.fs b/Point-free/Point-free/Program.fs new file mode 100644 index 0000000..258253d --- /dev/null +++ b/Point-free/Point-free/Program.fs @@ -0,0 +1,12 @@ +// изначальная функция +let funcToList x l = List.map (fun y -> y * x) l + + // убрали список +let funcToList'1 x : int list -> int list = List.map (fun y -> y * x) + +// убрали функцию +let funcToList'2 x : int list -> int list = List.map ((*)x) + +// убрали переменную +let funcToList'3() : int -> int list -> int list = List.map << (*) + From d2b9e270591680654e2fb6ec91ef479f2a63502d Mon Sep 17 00:00:00 2001 From: MikePuzanov Date: Wed, 6 Apr 2022 14:28:39 +0300 Subject: [PATCH 2/3] test don't work:) --- Point-free/Point-free.Test/Point-freeTest.fs | 7 +++---- Point-free/Point-free/Program.fs | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Point-free/Point-free.Test/Point-freeTest.fs b/Point-free/Point-free.Test/Point-freeTest.fs index c779a7b..eb96906 100644 --- a/Point-free/Point-free.Test/Point-freeTest.fs +++ b/Point-free/Point-free.Test/Point-freeTest.fs @@ -6,8 +6,7 @@ open Program [] let checkEqualTest () = - let check x l = - funcToList x l = funcToList'3 () x l + let check x list = + funcToList x list = funcToList3 x list - - Check.QuickThrowOnFailure check \ No newline at end of file + Check.QuickThrowOnFailure check \ No newline at end of file diff --git a/Point-free/Point-free/Program.fs b/Point-free/Point-free/Program.fs index 258253d..2accec7 100644 --- a/Point-free/Point-free/Program.fs +++ b/Point-free/Point-free/Program.fs @@ -2,11 +2,10 @@ let funcToList x l = List.map (fun y -> y * x) l // убрали список -let funcToList'1 x : int list -> int list = List.map (fun y -> y * x) +let funcToList1 x : int list -> int list = List.map (fun y -> y * x) // убрали функцию -let funcToList'2 x : int list -> int list = List.map ((*)x) +let funcToList2 x : int list -> int list = List.map ((*)x) // убрали переменную -let funcToList'3() : int -> int list -> int list = List.map << (*) - +let funcToList3 = (*) >> List.map From bcac5d3b473ea2b11f4ade8eff0bf097c9e02f9f Mon Sep 17 00:00:00 2001 From: MikePuzanov Date: Tue, 26 Apr 2022 01:37:54 +0300 Subject: [PATCH 3/3] switch to classLibrary --- Point-free/Point-free.Test/Point-freeTest.fs | 2 +- Point-free/Point-free/Point-free.fsproj | 1 - Point-free/Point-free/Program.fs | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Point-free/Point-free.Test/Point-freeTest.fs b/Point-free/Point-free.Test/Point-freeTest.fs index eb96906..16ff981 100644 --- a/Point-free/Point-free.Test/Point-freeTest.fs +++ b/Point-free/Point-free.Test/Point-freeTest.fs @@ -2,7 +2,7 @@ module Point_free.Test open NUnit.Framework open FsCheck -open Program +open PointFree [] let checkEqualTest () = diff --git a/Point-free/Point-free/Point-free.fsproj b/Point-free/Point-free/Point-free.fsproj index 2cc950a..6643d0f 100644 --- a/Point-free/Point-free/Point-free.fsproj +++ b/Point-free/Point-free/Point-free.fsproj @@ -1,7 +1,6 @@  - Exe net6.0 Point_free Windows diff --git a/Point-free/Point-free/Program.fs b/Point-free/Point-free/Program.fs index 2accec7..f0845a6 100644 --- a/Point-free/Point-free/Program.fs +++ b/Point-free/Point-free/Program.fs @@ -1,3 +1,4 @@ +module PointFree // изначальная функция let funcToList x l = List.map (fun y -> y * x) l