Comments
Loading Dream Comments...
You must be logged in to write a comment - Log In
 
    
    
 Artist
                                
                                
                                    Artist
                                        Consider the initializer :
                                        rainbow <:: (red=$F00, orange=$F80, yellow=$FF0, green=$0F0, cyan=$0FF, blue=$00F, violet=$F0F);
                                        This creates a two row Buffer (table), whose first row is the symbol table :
                                        rainbow[0] .eq. ("red", "orange", "yellow", "green", "cyan", "blue",  "violet");
                                        and whose second row is the corresponding VGA colours :
                                        rainbow[1] .eq. ($F00, $F80, $FF0,  $0F0,  $0FF, $00F, $F0F);
                                        This can be used as both an "enum" (as in C++) an as a lookup table.  For example, let's get the name of the second colour :
                                        ttyout rainbow[0][2]; // This prints "orange"
                                        Now let's get its  VGA RGB value :
                                        ttyout .hex. rainbow[1][2]; // This prints $0F80
                                        Now let's get the enum position of "orange" :
                                        ttyout rainbow[0] .lookup. "orange";
                                        This prints 2 :)
                                        If the entire initialiser is the first line of a function definition, we can also say :
                                        ttyout .hex. orange; //  Again printing $0F80, the "value" of the local variable orange.