]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/wrap/strings/strings.factor
factor: trim using lists
[factor.git] / basis / wrap / strings / strings.factor
index ddfd053900fd949ea652e516a41c3115d52c336a..56863cdddaf8585e6f43e19684cf70aad3d00bac 100644 (file)
@@ -1,29 +1,26 @@
 ! Copyright (C) 2009 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
-USING: fry kernel math sequences splitting strings wrap ;
+USING: kernel math sequences splitting strings wrap ;
 IN: wrap.strings
 
 <PRIVATE
 
-: split-line ( string -- elements )
+: wrap-split-line ( string -- elements )
     dup [ " \t" member? not ] find drop 0 or
     [ f swap ] [ cut ] if-zero
     " \t" split harvest [ dup length 1 <element> ] map!
     swap [ 0 over length <element> prefix ] when* ;
 
-: split-lines ( string -- elements-lines )
-    lines [ split-line ] map! ;
+: wrap-split-lines ( string -- elements-lines )
+    split-lines [ wrap-split-line ] map! ;
 
 : join-elements ( wrapped-lines -- lines )
-    [ unwords ] map! ;
-
-: join-lines ( strings -- string )
-    unlines ;
+    [ join-words ] map! ;
 
 PRIVATE>
 
 : wrap-lines ( string width -- newlines )
-    [ split-lines ] dip '[ _ wrap join-elements ] map! concat ;
+    [ wrap-split-lines ] dip '[ _ wrap join-elements ] map! concat ;
 
 : wrap-string ( string width -- newstring )
     wrap-lines join-lines ;