Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun row_size mat = length mat;
- fun col_size [] = 0
- | col_size (m::mat) = length m;
- fun valid_index mat (r,c) = if r<0 orelse r>row_size mat orelse c<0 orelse c>col_size mat then false else true;
- fun is_alive [] _ = false
- | is_alive (x::xs) (0,0) = hd(x)
- | is_alive (x::xs) (0,y) = if (valid_index (x::xs) (0,y)) then hd(List.drop(x,y))
- else false
- | is_alive (m::ms) (x,y) = if (valid_index (m::ms) (x,y)) then (is_alive ms (x-1,y))
- else false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement