Advertisement
Guest User

Untitled

a guest
May 18th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fun row_size mat = length mat;
  2. fun col_size [] = 0
  3. | col_size (m::mat) = length m;
  4.  
  5. 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;
  6.  
  7. fun is_alive [] _ = false
  8.     | is_alive (x::xs) (0,0) = hd(x)
  9.     | is_alive (x::xs) (0,y) = if (valid_index (x::xs) (0,y)) then hd(List.drop(x,y))
  10.                              else false
  11.     | is_alive (m::ms) (x,y) = if (valid_index (m::ms) (x,y)) then (is_alive ms (x-1,y))
  12.                              else false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement