Page 1 of 1

map::upFrom_nd

Posted: 31 Dec 2015 12:31
by Ferenc Nagy
Happy New Year!
I have a map of cells with key generation and coordinates.
I'd like to iterate on each cells belonging to the last generation, count their neighbors, and decide about the birth, death and survival of the cells.
Does the map::upFrom_nd procedure call below return only the cells of a given generation if cells having Generation>last_generation do not exist?
In other words, what is the sorting order of composite keys like the term g(generation,coordinates)?
Is the strongest sort key the generation, and the weakest the last integer of coordinate domain?

Code: Select all

domains     generation = positive.     gen_and_coord = g(generation,coordinates).     map_coordinates_to_cell = mapM{gen_and_coord, cell}.   properties     cell_map : map_coordinates_to_cell.     facts - for_properties     cell_map : map_coordinates_to_cell := erroneous.     predicates     generate:() procedure.   clauses  generate() :-         NextGeneration=last_generation+1,         if my_type=hexagonal then             LowestCoordinates=h(-max_abs_coord,-max_abs_coord,-max_abs_coord)         else             LowestCoordinates=r(-max_abs_coord,-max_abs_coord)         end if         _ =             [ Cell ||                 tuple(g(last_generation,Coordinates),Cell)=cell_map:upFrom_nd(g(last_generation,LowestCoordinate),                 NumInhabited=countNeigbors(g(last_generation,Coordinates),inhabited) % Place for decision about birth, death and survival of cells in the next generation.             ],        last_generation:=NextGeneration.  

Posted: 1 Jan 2016 14:10
by Thomas Linder Puls
Yes.

Notice that you can create maps based on your own comparison operation (e.g. mapM_redBlack::newCustom).