Column virtual sequence

slava 2006-10-21 20:51:38 +00:00
parent b4b81d9508
commit 6b14071f5f
2 changed files with 26 additions and 0 deletions

View File

@ -65,3 +65,22 @@ M: slice set-nth-unsafe slice@ set-nth-unsafe ;
M: slice like slice-seq like ;
M: slice thaw slice-seq thaw ;
TUPLE: column col seq ;
: column@ ( m section -- n seq )
dup column-col -rot column-seq nth ;
M: column length column-seq length ;
M: column nth column@ nth ;
M: column nth-unsafe column@ nth-unsafe ;
M: column set-nth column@ set-nth ;
M: column set-nth-unsafe column@ set-nth-unsafe ;
M: column like column-seq like ;
M: column thaw column-seq thaw ;

View File

@ -216,3 +216,10 @@ unit-test
[ V{ 1 2 3 } ]
[ 3 V{ 1 3 2 } clone [ push-new ] keep ] unit-test
! Columns
{ { 1 2 3 } { 4 5 6 } { 7 8 9 } } [ clone ] map "seq" set
[ { 1 4 7 } ] [ 0 "seq" get <column> >array ] unit-test
[ ] [ 1 "seq" get <column> [ sq ] inject ] unit-test
[ { 4 25 64 } ] [ 1 "seq" get <column> >array ] unit-test