Paste: how to balance branches
Author: | jimmack1963 |
Mode: | factor |
Date: | Fri, 25 Dec 2009 21:35:29 |
Plain Text |
USING: classes.tuple kernel prettyprint sequences ;
TUPLE: worker first last occupation ;
TUPLE: lawyer < worker ;
TUPLE: dentist < worker ;
: field-sets-class ( cls -- sub )
dup occupation>> {
{ "lawyer" [ lawyer ] }
{ "dentist" [ dentist ] }
[ drop worker ]
} case
[ tuple>array [ ] each ] dip boa nip ;
: field-sets-class-2 ( cls -- sub )
dup occupation>> {
{ "lawyer" [ lawyer ] }
{ "dentist" [ dentist ] }
[ drop "fake-obj" worker ]
} case
[ tuple>array [ ] each ] dip boa nip ;
"j" "mack" "lawyer" worker boa
field-sets-class .
Author: | blei |
Mode: | factor |
Date: | Fri, 25 Dec 2009 21:49:39 |
Plain Text |
: field-sets-class ( obj -- obj' )
dup occupation>> {
{ "lawyer" [ lawyer ] }
{ "dentist" [ dentist ] }
[ drop worker ]
} case new
[ [ <mirror> ] bi@ swap update ]
[ nip ] 2bi ;
New Annotation