Paste: A string replace word

Author: paldepind
Mode: factor
Date: Sat, 22 Dec 2012 12:13:45
Plain Text |
! Takes a string two characers and replace every instance of char1 with char2 in the string
: replace ( string char1 char1 -- string' ) 
    [ [ over = ] dip swap [ swap drop ] [ drop ] if ] 2curry map 
;

Annotation: My Formatting

Author: tgunr
Mode: factor
Date: Sat, 22 Dec 2012 14:07:56
Plain Text |
: replace ( string char char -- string' )
  [ 
    [ over = ] dip
    swap 
    [ swap drop ]
    [ drop ] if
  ] 2curry map ; 

Annotation: using fry

Author: noam
Mode: factor
Date: Sat, 22 Dec 2012 18:00:03
Plain Text |
: replace ( string char1 char1 -- string' )
    '[ dup _ = [ drop _ ] when ] map ;

New Annotation

Summary:
Author:
Mode:
Body: