Skip to content

Создала pull request HW4#4

Open
Nigma-Ks wants to merge 7 commits intomainfrom
HW4
Open

Создала pull request HW4#4
Nigma-Ks wants to merge 7 commits intomainfrom
HW4

Conversation

@Nigma-Ks
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown
Contributor

@yurii-litvinov yurii-litvinov left a comment

Choose a reason for hiding this comment

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

.DS_Store не надо выкладывать, должно быть в .gitignore

module Program =

[<EntryPoint>]
let main _ = 0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Это не надо

bracket = ']' || bracket = ')' || bracket = '}'

let getRelativeOpen (bracket: char) =
List.find (fun x -> snd x = bracket) bracketList |> fst
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Можно было bracketList сделать map-ом, тогда isOpen и isClose — это его Keys и Values, а эта штука работала бы за константу.

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

.NET 7 устарел

| _ -> false
else
internalBracketSequenceChecker tail bracketsStack
| [] -> if bracketsStack = [] then true else false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

😱


File.WriteAllText(phoneBaseFile, json)

let isContactInFile nameForFind phoneForFind phoneBaseFile =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"ForFind" не говорят. Говорят "ToFind" или что-то такое

Comment on lines +37 to +49
let writePhoneBaseToFile (phoneBase: Contact List) phoneBaseFile =
writeContactsToFile
(List.filter (fun contact -> not (isContactInFile contact.Name contact.Phone phoneBaseFile)) phoneBase)
phoneBaseFile

let writePhoneBaseFromFile (phoneBase: Contact List) phoneBaseFile =
let baseInFile = readContactsFromFile phoneBaseFile

let newPhoneBase =
phoneBase
@ (List.filter (fun contact -> not (isContactInBase contact.Name contact.Phone phoneBase)) baseInFile)

newPhoneBase
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Зачем так извращаться и потом склеивать контакты в базе и контакты в файле в операции записи? Проще и логичнее было бы грузить всё, что есть в файле, в начале работы, и при сохранении просто затирать весь файл контактами из текущей базы (которая точно содержит всё, что было в файле, потому что мы его загрузили до этого).

Comment on lines +25 to +26
for contact in contactList do
printfn "%s" (stringContact contact)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Мутабельное состояние было ещё запрещено в этой задаче

let addContactsToFile (phoneBase: Contact list) =
writePhoneBaseToFile phoneBase phoneBaseFile

let Run =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Функции называются со строчной

&& (func'3 x l = func'4 x l)
&& (func'4 x l = func'5 x l)

Check.Quick functionResAreEq
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Опять-таки, Check.Quick не пойдёт

Comment on lines +9 to +10
let brSeqCorr = "(({})[])"
let brSeqIncorr = "((({})[])"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Не сокращайте имена

Comment on lines +6 to +10
let isOpen (bracket: char) =
bracket = '(' || bracket = '{' || bracket = '['

let isClose (bracket: char) =
bracket = ']' || bracket = ')' || bracket = '}'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Есть же bracketList (который, правда, уже не List). А то если хочется новый вид скобок, надо будет тут поправить и там поправить, что неудобно

let isContactInBase nameForFind phoneToFind phoneBase =
List.exists (fun contact -> contact.Name = nameForFind || contact.Phone = phoneToFind) phoneBase

let writePhoneBaseFromFile phoneBaseFile = readContactsFromFile phoneBaseFile
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

read, может быть?

Comment on lines +30 to +32
let isContactInFile nameForFind phoneToFind phoneBaseFile =
List.exists (fun contact -> contact.Name = nameForFind || contact.Phone = phoneToFind)
<| readContactsFromFile phoneBaseFile
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Это, кажется, не используется нигде

()
else
let json =
JsonConvert.SerializeObject((contacts @ (readContactsFromFile phoneBaseFile)), Formatting.Indented)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

А зачем всё-таки их мерджить с содержимым файла перед записью? Мы ведь в contacts перед началом работы данные из файла уже зачитали, так что получатся дублирующиеся записи, нет?

let addContactsToFile (phoneBase: Contact list) =
writeContactsToFile phoneBase phoneBaseFile

let run =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Оно как будто бы функция, но на самом деле значение типа unit. Выглядит странно (как будто у программы точки входа нет).

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