Paste: table-block (please suggest simplifications)
Author: | randy7 |
Mode: | factor |
Date: | Mon, 5 Jan 2009 11:23:11 |
Plain Text |
USING: math.ranges ;
: take-one ( seq-table horizontal-n vertical-n -- item )
[ swap nth ] [ swap nth ] bi* ;
: extract2 ( range -- n1 n2 )
[ first 1- ] [ second 1- ] bi ;
: x-range ( x1 x2 -- range ) 1+ 2array ;
: y-range ( y1 y2 -- range ) 1+ 2array ;
: take-few ( seq-table horizontal-range vertical-range -- block )
swap [ '[ _ extract2 ] dip subseq ] dip
'[ [ _ extract2 ] dip subseq ] map
concat ;
{
{ 1 2 3 }
{ 4 5 6 }
{ 7 8 9 }
}
1 2 x-range
1 2 y-range take-few
Author: | randy7 |
Mode: | factor |
Date: | Mon, 5 Jan 2009 11:27:53 |
Plain Text |
: take-one ( seq-table horizontal-n vertical-n -- item )
[ 1- ] bi@
[ swap nth ] [ swap nth ] bi* ;
New Annotation