Paste: small example

Author: zbrown
Mode: factor
Date: Wed, 4 Nov 2009 14:10:16
Plain Text |
USING: kernel prettyprint ;
IN: testing

: getColorFromInt ( int -- string )
    {
        { [ dup 0 = ] [ "RED" ] }
        { [ dup 1 = ] [ "BLUE" ] }
        { [ dup 2 = ] [ "GREEN" ] }
        { [ dup 3 = ] [ "PURPLE" ] }
    } cond swap drop ;

: testMe ( -- )
    3 getColorFromInt . ;

MAIN: testMe

Annotation: code is data, data is code

Author: hsuh
Mode: factor
Date: Wed, 4 Nov 2009 17:37:02
Plain Text |
Try something using at, like:

2 H{ { 0 "RED"    } 
     { 1 "BLUE"   } 
     { 2 "GREEN"  } 
     { 3 "PURPLE" } } at

New Annotation

Summary:
Author:
Mode:
Body: