Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse #3

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions src/Homework1/Homework1.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</PropertyGroup>
<ItemGroup>
<Content Include="paket.references" />
<Compile Include="ListReverse.fs" />
<Compile Include="Main.fs" />
</ItemGroup>
<Import Project="..\..\.paket\Paket.Restore.targets" />
Expand Down
19 changes: 19 additions & 0 deletions src/Homework1/ListReverse.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Homework1

/// <summary>
/// Module that contains function for list reversing.
/// </summary>
module ListReverse =
/// <summary>
/// Reverse the list.
/// </summary>
/// <param name="list">List to reverse.</param>
let reverse list =
let rec reverseRec acc tail =
match tail with
| [] -> acc
| hd :: tl -> reverseRec (hd :: acc) tl

match list with
| [] -> []
| list -> reverseRec [] list
Comment on lines +17 to +19

Choose a reason for hiding this comment

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

Здесь паттерн-матчинг не нужен

Suggested change
match list with
| [] -> []
| list -> reverseRec [] list
reverseRec [] list

3 changes: 1 addition & 2 deletions tests/Homeworks.Tests/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ let allTests = testList "all Tests" []

[<EntryPoint>]
let main argv =
allTests
|> runTestsWithCLIArgs [] argv
allTests |> runTestsWithCLIArgs [] argv