Open
Conversation
DedSec256
suggested changes
May 28, 2022
| let computer = Array.get computers i | ||
| printfn "\nName: %i, Operation system: %s, is infected: %b" (i + 1) computer.Name computer.Virus | ||
|
|
||
| new (matrix: int[,], computers: Computer[]) = Network(matrix, computers) |
There was a problem hiding this comment.
похоже, этот конструктор не тестировался, ведь он вызывает сам себя!
Suggested change
| new (matrix: int[,], computers: Computer[]) = Network(matrix, computers) | |
| new (matrix: int[,], computers: Computer[]) = Network(matrix, computers, []) |
Comment on lines
43
to
46
| printfn "\n\nStep: %i" countOfSteps | ||
| for i in 0 .. computers.Length - 1 do | ||
| let computer = Array.get computers i | ||
| printfn "\nName: %i, Operation system: %s, is infected: %b" (i + 1) computer.Name computer.Virus |
There was a problem hiding this comment.
Suggested change
| printfn "\n\nStep: %i" countOfSteps | |
| for i in 0 .. computers.Length - 1 do | |
| let computer = Array.get computers i | |
| printfn "\nName: %i, Operation system: %s, is infected: %b" (i + 1) computer.Name computer.Virus | |
| printfn "\n\nStep: %i" countOfSteps | |
| computers |> Array.iteri(fun i computer -> printfn $"\nName: %i{i + 1}, Operation system: %s{computer.Name}, is infected: %b{computer.Virus}") |
| type public Network(matrix : int [,], computers : Computer[], virus : int list) = | ||
| let matrix = matrix | ||
| let computers = computers | ||
| let mutable state = true |
There was a problem hiding this comment.
не очень понятное именование. Вероятно, имелось в виду IsAnyInfected?
Comment on lines
32
to
40
| for i in 0 .. computers.Length - 1 do | ||
| if (Array.get computers i).Virus then | ||
| for j in 0 .. computers.Length - 1 do | ||
| let comp = Array.get computers j | ||
| if (Array2D.get matrix i j = 1 && not comp.Virus) then | ||
| state <- true | ||
| let random = Random().NextDouble() | ||
| if comp.Probability >= random then | ||
| comp.Virus <- true |
There was a problem hiding this comment.
Возможно это переписать как-то более функционально?
DedSec256
approved these changes
Jun 1, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.