Paste: style question
Author: | ben_m |
Mode: | factor |
Date: | Fri, 5 Feb 2010 00:08:53 |
Plain Text |
: make-table ( x y -- table )
over * [1,b] swap group ;
: make-table ( x y -- table )
[ * [1,b] ] [ drop group ] 2bi ;
Author: | ben_m |
Mode: | factor |
Date: | Fri, 5 Feb 2010 00:09:59 |
Plain Text |
( scratchpad ) 2 5 make-table .
{ { 1 2 } { 3 4 } { 5 6 } { 7 8 } { 9 10 } }
Author: | ben_m |
Mode: | factor |
Date: | Fri, 5 Feb 2010 00:13:07 |
Plain Text |
USING: grouping io kernel locals math math.parser math.ranges
sequences ;
IN: print-table
: dimensions ( table -- x y )
[ length ] [ first length ] bi ;
: digits ( n -- n )
number>string length ;
: pad ( n n -- str )
[ number>string ] dip CHAR: space pad-head ;
: make-table ( x y -- table )
[ * [1,b] ] 2keep drop group ;
: print-table ( table -- )
dup dimensions * digits
[
[ pad ] curry map " " join print
] curry each ;
New Annotation