Skip to content

Conversation

@MikePuzanov
Copy link
Owner

No description provided.

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)

Choose a reason for hiding this comment

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

похоже, этот конструктор не тестировался, ведь он вызывает сам себя!

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

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

не очень понятное именование. Вероятно, имелось в виду 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

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