Paste: first program
Author: | yac |
Mode: | factor |
Date: | Mon, 16 May 2011 22:41:50 |
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 ] dip ] dip 3array concat ;
: mirror dup reverse rest append ;
: line half-line mirror "\n" append ;
: half-diamond
CHAR: A over [a,b] [ over swap line ] map nip ;
: 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