15.3.4 Domains of Atoms and Integers

We start with domains whose elements are atoms or integer. These can be created as follows:

<Make Domain>=
fun{Make Es} %% list(feature) -> domain
      IndTable = {List.toTuple unit Es}    %% record(int:feature)
      fun{ToElement Ind}
         IndTable.(Ind+1)
      end 
      Size = {Length Es}
      EleTable = {MakeRecord unit Es}      %% record(feature:int)
      %% the fields of EleTable are still free variables
      for I in 0..Size-do 
         EleTable.{ToElement I} = I
      end 
      fun{ToIndex Ele}
         EleTable.Ele
      end 
   in  
      unit(toIndex  : ToIndex
           toElement: ToElement
           size     : Size)    
   end


Denys Duchier, Claire Gardent and Joachim Niehren
Version 1.3.99 (20050412)