Paste: reconstruct
Author: | erg |
Mode: | factor |
Date: | Fri, 20 Aug 2010 01:58:10 |
Plain Text |
MACRO:: row>tuples ( spec -- quot )
0 :> i!
spec [
unclip :> ( setters tuple-class )
[
tuple-class , \ new ,
setters [ i , \ pick , \ nth-unsafe , , i 1 + i! ] each
\ , ,
] [ ] make
] map [ ] concat-as '[ _ { } make nip ] ;
MACRO: rows>tuples ( spec -- quot )
'[ [ _ row>tuples ] map ] ;
TUPLE: bag id beans ;
TUPLE: bean id color ;
{ { 0 0 "blue" } { 0 1 "red" } }
{ { bag >>id } { bean >>id >>color } } rows>tuples .
{
{ T{ bag { id 0 } } T{ bean { id 0 } { color "blue" } } }
{ T{ bag { id 0 } } T{ bean { id 1 } { color "red" } } }
}
New Annotation