Paste: Excel column headers
Author: | missingfaktor |
Mode: | factor |
Date: | Thu, 22 Dec 2011 13:52:41 |
Plain Text |
USING: kernel math math.ranges sequences strings ;
IN: excel-columns
: alphabet ( -- seq ) CHAR: A CHAR: Z [a,b] ;
: nth-char ( n -- char ) 25 + 26 mod alphabet nth 1string ;
: break-26 ( m -- n o ) 26 [ /i ] [ mod ] 2bi ;
: column-id ( i -- str ) dup 26 <= [ nth-char ] [ break-26 [ column-id ] bi@ append ] if ;
: test-run ( -- ) 1000 [1,b] [ dup column-id 2array . ] each
MAIN: test-run
New Annotation