Paste: Motivated use of spin

Author: Loryn Jenkins
Mode: factor
Date: Thu, 4 Apr 2013 10:55:07
Plain Text |
: fd>string ( x -- y ) 
    [ radix>> ] [ value>> ] bi number>string 2dup length - 0
    <=> {
       { +lt+ [ "." spin insert-at* ] }
       { +eq+ [ "0." prepend nip ] } 
       { +gt+ [ dup length swapd - zero-string "0." spin 3append ] }
    } case ; 

Annotation: Supporting words

Author: Loryn Jenkins
Mode: factor
Date: Thu, 4 Apr 2013 11:01:52
Plain Text |
: insert-at* ( this-seq into-seq at* -- newseq )
     cut* swapd 3append ;
     
: zero-string ( length -- string )
    10^ number>string 1 tail ;

New Annotation

Summary:
Author:
Mode:
Body: