Paste: replacing booleans with string values

Author: otoburb
Mode: factor
Date: Wed, 18 May 2011 04:15:17
Plain Text |
H{ 
  { "value1" t }
  { "value2" f }
  { "value3" 3 }
} 

: boolean-string-substitute ( assoc -- assoc' )
  [ dup [ t = [ drop "True" ] when ] [ f = [ drop "False" ] when ] bi ] assoc-map ;

Annotation: .

Author: noam
Mode: factor
Date: Wed, 18 May 2011 11:59:51
Plain Text |
! you can squeeze it to one word, but usually it's cleaner this way

: bool>string ( ? -- str )
    {
        { t [ "True" ] }
        { f [ "False" ] }
        [ ]
    } case ;

: boolean-string-substitute ( assoc -- assoc' )
    [ bool>string ] assoc-map ;

New Annotation

Summary:
Author:
Mode:
Body: