Paste: tkv (phar out shite mang!)
Author: | dharmatech |
Mode: | factor |
Date: | Tue, 14 Oct 2008 08:44:43 |
Plain Text |
USING: kernel accessors assocs multi-methods ;
IN: tkv
GENERIC: key ( tbl key -- tbl )
GENERIC: val ( tbl val -- tbl )
TUPLE: tkv tbl key val ;
METHOD: key { assoc object } >r >r tkv new r> >>tbl r> >>key ;
METHOD: key { tkv object } over val>> swap pick tbl>> set-at tbl>> ;
METHOD: val { assoc object } >r >r tkv new r> >>tbl r> >>val ;
METHOD: val { tkv object } over key>> pick tbl>> set-at tbl>> ;
: key-in ( key tbl -- tbl ) swap key ;
: val-in ( val tbl -- tbl ) swap val ;
New Annotation