-
Notifications
You must be signed in to change notification settings - Fork 0
Local network #10
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
base: master
Are you sure you want to change the base?
Local network #10
Conversation
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
похоже, этот конструктор не тестировался, ведь он вызывает сам себя!
| new (matrix: int[,], computers: Computer[]) = Network(matrix, computers) | |
| new (matrix: int[,], computers: Computer[]) = Network(matrix, computers, []) |
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не очень понятное именование. Вероятно, имелось в виду IsAnyInfected?
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Возможно это переписать как-то более функционально?
No description provided.