Skip to content

Conversation

@MikePuzanov
Copy link
Owner

No description provided.

let addTest () =
let book = addPhone "Oleg" "12345" book

book |> should contain {Name = "Oleg"; Phone = "12345"}

Choose a reason for hiding this comment

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

здесь было бы лучше проверить весь справочник. Вдруг addPhone перетирает остальные записи?

let command = getCommand ()
match command with
| "0" -> ()
| "1" -> addPhone (getName ()) (getPhone ()) book |> program

Choose a reason for hiding this comment

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

было бы немного читабельнее

Suggested change
| "1" -> addPhone (getName ()) (getPhone ()) book |> program
| "1" -> book |> addPhone (getName ()) (getPhone ()) |> program

// поиск имени по телефону
let rec findNameByPhone phone (book : BookOfNumber list) =
let getFirst ({Name = a; Phone = b} : BookOfNumber) = a
book |> List.filter (fun {Name = _; Phone = x} -> x = phone) |> List.map(getFirst)

Choose a reason for hiding this comment

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

Можно записать так

Suggested change
book |> List.filter (fun {Name = _; Phone = x} -> x = phone) |> List.map(getFirst)
book |> List.filter (fun {Phone = x} -> x = phone) |> List.map(fun {Name = x} -> x)

Comment on lines +25 to +28
let person (book : BookOfNumber list) = book.Head
if (not(book |> List.isEmpty)) then
printf "%s %s\n" (person book).Name (person book).Phone
printAll book.Tail

Choose a reason for hiding this comment

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

проще было бы через паттерн-матчинг со списком записать

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.

3 participants