Skip to content
Open

test #11

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions test2/Test.Test/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Program =

[<EntryPoint>]
let main _ = 0
12 changes: 12 additions & 0 deletions test2/Test.Test/SeqTest.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Test.SquareTest

open NUnit.Framework
open FsUnit
open SeqTest


[<Test>]
let SeqTest () =
let first15Nums = [ for i in 0 .. 14 -> Seq.item i (seqMake()) ]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let first15Nums = [ for i in 0 .. 14 -> Seq.item i (seqMake()) ]
let first15Nums = seqMake() |> Seq.take 15


first15Nums |> should equal [ 1; 2; 2; 3; 3; 3; 4; 4; 4; 4; 5; 5; 5; 5; 5]
27 changes: 27 additions & 0 deletions test2/Test.Test/Test.Test.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>

<IsPackable>false</IsPackable>
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>

<ItemGroup>
<Compile Include="SeqTest.fs" />
<Compile Include="Program.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FsUnit" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\test2\test2.fsproj" />
</ItemGroup>

</Project>
22 changes: 22 additions & 0 deletions test2/test2.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "test2", "test2\test2.fsproj", "{41A6A315-3580-4C37-BE39-73B0B203619A}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Test.Test", "Test.Test\Test.Test.fsproj", "{41756876-4F39-4C44-AEF1-1C52CAA3C130}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{41A6A315-3580-4C37-BE39-73B0B203619A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41A6A315-3580-4C37-BE39-73B0B203619A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41A6A315-3580-4C37-BE39-73B0B203619A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41A6A315-3580-4C37-BE39-73B0B203619A}.Release|Any CPU.Build.0 = Release|Any CPU
{41756876-4F39-4C44-AEF1-1C52CAA3C130}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41756876-4F39-4C44-AEF1-1C52CAA3C130}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41756876-4F39-4C44-AEF1-1C52CAA3C130}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41756876-4F39-4C44-AEF1-1C52CAA3C130}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
13 changes: 13 additions & 0 deletions test2/test2/Seq.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module SeqTest
let seqMake () =
let rec seqCheck element i = i <> element

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а зачем это вынесено в отдельную функцию? Она ещё и не рекурсивна (:

let rec sequence element list i =
seq {
if seqCheck element i then
yield element
yield! sequence element (element :: list) (i + 1)
else
yield! sequence (element + 1) list 0

}
sequence 1 [] 0
34 changes: 34 additions & 0 deletions test2/test2/Square.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module test2.Square

open System

let buildSquare n =

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не самое изящное решение, но засчитано.

let rec buildFirstAndLastLine i n =
if i = n then
printf"*\n"
else
printf"*"
buildFirstAndLastLine (i + 1) n
let rec buildOtherLine i n =
if i = n then
printf"*\n"
else if i = 1 then
printf"*"
buildOtherLine (i + 1) n
else
printf" "
buildOtherLine (i + 1) n
let rec square i =
if i < 1 then raise(ArgumentException())
else if i = n then
buildFirstAndLastLine 1 n
else if i = 1 then
buildFirstAndLastLine 1 n
square (i + 1)
else
buildOtherLine 1 n
square (i + 1)

square 1

buildSquare 2
14 changes: 14 additions & 0 deletions test2/test2/test2.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<Compile Include="Seq.fs" />
<Compile Include="Square.fs" />
</ItemGroup>

</Project>