Some remarks :
(削除) your, you might want to explore the Array and List sections of the standard library, they are full of very useful functions that will speed-up your development.combine
function is in factList.zip
(削除ここまで)createRandomBoard
is not a function and thus will always be the same array (arrays being mutable, you might come across some unwanted side effects if you use it twice in the same code). It could be rewritten usingArray.init
:let createRandomBoard () = let rnd = new Random(10) Array.init size (fun _ -> if rnd.NextDouble() < 0.2 then 1 else 0)
you are using '0' and '1' to model your two states, why not booleans ? It would eliminate the need for some tests.
Array.set ar ind x
can be rewritten asar.[ind] <- x
(but, as Foggy Finder Foggy Finder said, you would lose some type inference ifar
has not been identified as an array before)forms such as :
[1..n] |> List.iter f
are indeed functional but inefficient and, I believe, not as readable as using a loop. F# is especially powerful because it is a hybrid language (and not a purely functional one) : don't hesitate to leverage arrays and loops when it makes sense.
Some remarks :
(削除) your, you might want to explore the Array and List sections of the standard library, they are full of very useful functions that will speed-up your development.combine
function is in factList.zip
(削除ここまで)createRandomBoard
is not a function and thus will always be the same array (arrays being mutable, you might come across some unwanted side effects if you use it twice in the same code). It could be rewritten usingArray.init
:let createRandomBoard () = let rnd = new Random(10) Array.init size (fun _ -> if rnd.NextDouble() < 0.2 then 1 else 0)
you are using '0' and '1' to model your two states, why not booleans ? It would eliminate the need for some tests.
Array.set ar ind x
can be rewritten asar.[ind] <- x
(but, as Foggy Finder said, you would lose some type inference ifar
has not been identified as an array before)forms such as :
[1..n] |> List.iter f
are indeed functional but inefficient and, I believe, not as readable as using a loop. F# is especially powerful because it is a hybrid language (and not a purely functional one) : don't hesitate to leverage arrays and loops when it makes sense.
Some remarks :
(削除) your, you might want to explore the Array and List sections of the standard library, they are full of very useful functions that will speed-up your development.combine
function is in factList.zip
(削除ここまで)createRandomBoard
is not a function and thus will always be the same array (arrays being mutable, you might come across some unwanted side effects if you use it twice in the same code). It could be rewritten usingArray.init
:let createRandomBoard () = let rnd = new Random(10) Array.init size (fun _ -> if rnd.NextDouble() < 0.2 then 1 else 0)
you are using '0' and '1' to model your two states, why not booleans ? It would eliminate the need for some tests.
Array.set ar ind x
can be rewritten asar.[ind] <- x
(but, as Foggy Finder said, you would lose some type inference ifar
has not been identified as an array before)forms such as :
[1..n] |> List.iter f
are indeed functional but inefficient and, I believe, not as readable as using a loop. F# is especially powerful because it is a hybrid language (and not a purely functional one) : don't hesitate to leverage arrays and loops when it makes sense.
Some remarks :
your
combine
function is in factList.zip
(削除) your, you might want to explore the Array and List sections of the standard library, they are full of very useful functions that will speed-up your development.combine
function is in factList.zip
(削除ここまで)createRandomBoard
is not a function and thus will always be the same array (arrays being mutable, you might come across some unwanted side effects if you use it twice in the same code). It could be rewritten usingArray.init
:let createRandomBoard () = let rnd = new Random(10) Array.init size (fun _ -> if rnd.NextDouble() < 0.2 then 1 else 0)
you are using '0' and '1' to model your two states, why not booleans ? It would eliminate the need for some tests.
Array.set ar ind x
can be rewritten asar.[ind] <- x
(but, as Foggy Finder said, you would lose some type inference ifar
has not been identified as an array before)forms such as :
[1..n] |> List.iter f
are indeed functional but inefficient and, I believe, not as readable as using a loop. F# is especially powerful because it is a hybrid language (and not a purely functional one) : don't hesitate to leverage arrays and loops when it makes sense.
Some remarks :
your
combine
function is in factList.zip
, you might want to explore the Array and List sections of the standard library, they are full of very useful functions that will speed-up your development.createRandomBoard
is not a function and thus will always be the same array (arrays being mutable, you might come across some unwanted side effects if you use it twice in the same code). It could be rewritten usingArray.init
:let createRandomBoard () = let rnd = new Random(10) Array.init size (fun _ -> if rnd.NextDouble() < 0.2 then 1 else 0)
you are using '0' and '1' to model your two states, why not booleans ? It would eliminate the need for some tests.
Array.set ar ind x
can be rewritten asar.[ind] <- x
forms such as :
[1..n] |> List.iter f
are indeed functional but inefficient and, I believe, not as readable as using a loop. F# is especially powerful because it is a hybrid language (and not a purely functional one) : don't hesitate to leverage arrays and loops when it makes sense.
Some remarks :
(削除) your, you might want to explore the Array and List sections of the standard library, they are full of very useful functions that will speed-up your development.combine
function is in factList.zip
(削除ここまで)createRandomBoard
is not a function and thus will always be the same array (arrays being mutable, you might come across some unwanted side effects if you use it twice in the same code). It could be rewritten usingArray.init
:let createRandomBoard () = let rnd = new Random(10) Array.init size (fun _ -> if rnd.NextDouble() < 0.2 then 1 else 0)
you are using '0' and '1' to model your two states, why not booleans ? It would eliminate the need for some tests.
Array.set ar ind x
can be rewritten asar.[ind] <- x
(but, as Foggy Finder said, you would lose some type inference ifar
has not been identified as an array before)forms such as :
[1..n] |> List.iter f
are indeed functional but inefficient and, I believe, not as readable as using a loop. F# is especially powerful because it is a hybrid language (and not a purely functional one) : don't hesitate to leverage arrays and loops when it makes sense.
- 131
- 4
Some remarks :
your
combine
function is in factList.zip
, you might want to explore the Array and List sections of the standard library, they are full of very useful functions that will speed-up your development.createRandomBoard
is not a function and thus will always be the same array (arrays being mutable, you might come across some unwanted side effects if you use it twice in the same code). It could be rewritten usingArray.init
:let createRandomBoard () = let rnd = new Random(10) Array.init size (fun _ -> if rnd.NextDouble() < 0.2 then 1 else 0)
you are using '0' and '1' to model your two states, why not booleans ? It would eliminate the need for some tests.
Array.set ar ind x
can be rewritten asar.[ind] <- x
forms such as :
[1..n] |> List.iter f
are indeed functional but inefficient and, I believe, not as readable as using a loop. F# is especially powerful because it is a hybrid language (and not a purely functional one) : don't hesitate to leverage arrays and loops when it makes sense.
Some remarks :
your
combine
function is in factList.zip
, you might want to explore the Array and List sections of the standard library, they are full of very useful functions that will speed-up your development.createRandomBoard
is not a function and could be rewritten usingArray.init
:let createRandomBoard () = let rnd = new Random(10) Array.init size (fun _ -> if rnd.NextDouble() < 0.2 then 1 else 0)
you are using '0' and '1' to model your two states, why not booleans ? It would eliminate the need for some tests.
Array.set ar ind x
can be rewritten asar.[ind] <- x
forms such as :
[1..n] |> List.iter f
are indeed functional but inefficient and, I believe, not as readable as using a loop. F# is especially powerful because it is a hybrid language (and not a purely functional one) : don't hesitate to leverage arrays and loops when it makes sense.
Some remarks :
your
combine
function is in factList.zip
, you might want to explore the Array and List sections of the standard library, they are full of very useful functions that will speed-up your development.createRandomBoard
is not a function and thus will always be the same array (arrays being mutable, you might come across some unwanted side effects if you use it twice in the same code). It could be rewritten usingArray.init
:let createRandomBoard () = let rnd = new Random(10) Array.init size (fun _ -> if rnd.NextDouble() < 0.2 then 1 else 0)
you are using '0' and '1' to model your two states, why not booleans ? It would eliminate the need for some tests.
Array.set ar ind x
can be rewritten asar.[ind] <- x
forms such as :
[1..n] |> List.iter f
are indeed functional but inefficient and, I believe, not as readable as using a loop. F# is especially powerful because it is a hybrid language (and not a purely functional one) : don't hesitate to leverage arrays and loops when it makes sense.