Paste: derrida challenge #1

Author: ben_m
Mode: factor
Date: Fri, 5 Feb 2010 00:18:11
Plain Text |
! Copyright (C) 2010 Benjamin Meinl.
! See http://factorcode.org/license.txt for BSD license.
USING: fry grouping io kernel 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 ] map " " join print ] each ;

New Annotation

Summary:
Author:
Mode:
Body: