Skip to content
Open
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
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@ run
.gcda
.gcno

FirstSteps/FirstSteps/bin/*
FirstSteps/FirstSteps/obj/*
**/bin/*
**/obj/*

*.suo
Binary file added lastSteps/.vs/lastSteps/v15/.suo
Binary file not shown.
40 changes: 40 additions & 0 deletions lastSteps/Tests/Program2.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
open FsUnit
open hw
open FsCheck

let test ()=
//=======================<task1>=======================
let ans =
Rounding 3 {
let! a = 2.0 / 12.0
let! b = 3.5
return a / b
}
ans |> should equal 0.048
//=======================</task1>======================
//=======================<task2>=======================
let ans =
Calculate() {
let! x = "1"
let! y = "2"
let z = x + y
return z
}
ans |> should equal <| Some 3

let ans =
Calculate() {
let! x = "1"
let! y = "ololo"
let z = x + y
return z
}
ans |> should equal <| None
//=======================</task2>======================
printfn "ok"

[<EntryPoint>]
let main argv =
test()
0 // return an integer exit code

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

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program2.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FsCheck" Version="2.10.9" />
<PackageReference Include="FsUnit" Version="3.1.0" />
</ItemGroup>

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

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

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2027
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "lastSteps", "lastSteps\lastSteps.fsproj", "{0D1A3D07-30A9-421F-9367-6AD852CF97D5}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Tests", "Tests\Tests.fsproj", "{DDA2F794-D1CC-4046-9237-3B2C1F7D7867}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0D1A3D07-30A9-421F-9367-6AD852CF97D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0D1A3D07-30A9-421F-9367-6AD852CF97D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D1A3D07-30A9-421F-9367-6AD852CF97D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0D1A3D07-30A9-421F-9367-6AD852CF97D5}.Release|Any CPU.Build.0 = Release|Any CPU
{DDA2F794-D1CC-4046-9237-3B2C1F7D7867}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DDA2F794-D1CC-4046-9237-3B2C1F7D7867}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DDA2F794-D1CC-4046-9237-3B2C1F7D7867}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DDA2F794-D1CC-4046-9237-3B2C1F7D7867}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1507EBBF-D6FE-4AEA-B727-11CB0FEC1811}
EndGlobalSection
EndGlobal
36 changes: 36 additions & 0 deletions lastSteps/lastSteps/Program2.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Learn more about F# at http://fsharp.org
module hw

open System
open System.IO

let read = bigint.Parse << Console.ReadLine
let readInt = Int32.Parse << Console.ReadLine
let readStr = Console.ReadLine
let rnd = System.Random()

//=======================<task1>=======================
type Rounding (accuracy : int) =
member this.Bind(x : double, f) =
f <| Math.Round (x, accuracy)
member this.Return(x : double) =
Math.Round (x, accuracy)


//=======================</task1>======================

//=======================<task2>=======================
type Calculate () =
member this.Bind(x, f) =
try
f <| Int32.Parse x
with
| :? FormatException -> None

Choose a reason for hiding this comment

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

Лучше tryParse

member this.Return(x) =
Some x
//=======================</task2>======================
(*_*)
[<EntryPoint>]
let main argv =

0 // return an integer exit code
12 changes: 12 additions & 0 deletions lastSteps/lastSteps/lastSteps.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program2.fs" />
</ItemGroup>

</Project>