Skip to content

Comments

Test1#9

Open
Volodya-Petrov wants to merge 1 commit intomainfrom
test
Open

Test1#9
Volodya-Petrov wants to merge 1 commit intomainfrom
test

Conversation

@Volodya-Petrov
Copy link
Owner

No description provided.

Copy link

@DedSec256 DedSec256 left a comment

Choose a reason for hiding this comment

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

  1. List.min -- 10/10
  2. Tree to list -- хорошее решение, однако без хвостовой рекурсии, поэтому 8.5/10

[<Test>]
let TestEquivalenceForMinFunctions () =
let funEqual (list: int list) =
if List.isEmpty list then true else

Choose a reason for hiding this comment

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

Кажется, можно задать сид для генерации непустых списков, но и так можно

Comment on lines +11 to +14
match filter value with
| true ->
result (value :: acc)
| false -> result acc

Choose a reason for hiding this comment

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

паттерн-матчинг для bool -- это сильно! Хватило бы и простого if, но не страшно.

| Tree of 'a * Tree<'a> * Tree<'a>
| Empty

let treeFilter tree filter =

Choose a reason for hiding this comment

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

Достаточно оптимальное решение, однако задачу возможно решить через хвостовую рекурсию.

if List.isEmpty list then
raise (System.ArgumentException("Список пуст"))
else
List.fold (fun acc x -> if x < acc then x else acc) (List.head list) list

Choose a reason for hiding this comment

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

к слову, можно было через List.reduce min list (:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants