Paste: diamond update
Author: | yac |
Mode: | factor |
Date: | Tue, 17 May 2011 17:34:35 |
Plain Text |
USING: kernel io math math.ranges sequences strings arrays command-line namespaces ;
IN: diamond
: >index CHAR: A - 1 + ;
: n-spc [ CHAR: \s ] "" replicate-as ;
: half-line*
[ - ] keep dup >index 1 - ;
: half-line
half-line* [ n-spc ] [ 1string ] [ n-spc ] tri* 3append ;
: mirror dup reverse rest append ;
: line half-line mirror "\n" append ;
: half-diamond
CHAR: A over [a,b] [ line ] with map ;
: diamond half-diamond mirror concat ;
command-line get dup length 1 =
[ first first diamond print ]
[ "Give me a letter as only argument, dear sir." print ]
if
New Annotation