I declared the following types:
type cell = { #dead; #alive};
type universe = {
width : Nat;
height : Nat;
cells : [var cell]
};
var universe1 : universe ={
width = 4;
height = 4;
cells = [var
#dead, #alive, #alive, #dead,
#dead, #alive, #alive, #alive,
#dead, #dead, #dead, #dead,
#alive, #alive, #alive ,#dead
];
var universe2 : universe ={
width = 4;
height = 4;
cells = [var
#dead, #alive, #alive, #dead,
#dead, #alive, #alive, #alive,
#dead, #dead, #dead, #dead,
#alive, #alive, #alive ,#dead
];
};
I now want to compare universe1.cells
and universe2.cells
with Array.equals
import Array āmo:stdlib/arrayā
if(Array.equals<cell>(universe1.cells : [var cell], universe2.cells : [var cell], eq)) Debug.print(āhiā);
My problem - as you probably noticed - is, that the universe.cells produces [var cell]
and i donāt understand how to either declare <var cell>
(doesnt work) or type cell = var {#dead; #alive};
(doesnt work either).
The second problem is that i donāt understand how to compare two variant types (#dead
and #alive
) to check if theyāre equal (this is needed for the eq
function in Array.equals
from above). The old fashioned #dead == #alive
doesnt work.
Help would be highly appreciated!
@alexa.smith @hansl @enzo