On 21.04.2006, at 22:20, Chris Rathman wrote:
what's the best way to seamlessly go from an enumeration type (colors) into integers?

I would simply add some data abstraction layer which defines, e.g., EncColor and DecColor.

fun {MakeTable R}
   {Adjoin
    {List.toRecord unit {Map {Record.toListInd R} fun {$ F#X} X#F end}}
    R}
end
Colors = {MakeTable colors(beige coral mauve ochre)}
fun {EncColor X}
  Colors.X
end
fun {DecColor I}
   Colors.I
end

NB: This MakeTable implementation presupposes that your symbols are never integers, otherwise you might, e.g., encode by searching for the integer associated with some symbol.

Best,
Torsten

--
Torsten Anders
Sonic Arts Research Centre
Queen's University Belfast (UK)
www.torsten-anders.de


_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to