]> gitweb.factorcode.org Git - factor.git/commitdiff
sequences.extras: Add a couple words for prepending spaces to lines
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 8 Aug 2022 06:27:26 +0000 (01:27 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 8 Aug 2022 06:29:47 +0000 (01:29 -0500)
extra/sequences/extras/extras.factor

index dc56d117d478c7d7b27873fa10579a447b08df4c..0d37e3e14d118f96a3c9de09c4258144c6c767b2 100644 (file)
@@ -379,6 +379,12 @@ PRIVATE>
 : >string-list ( seq -- seq' )
     [ "\"" 1surround ] map "," join ;
 
+: with-string-lines ( str quot -- str' )
+    [ string-lines ] dip map "\n" join ; inline
+
+: prepend-lines-with-spaces ( str -- str' )
+    [ "    " prepend ] with-string-lines ;
+
 : one? ( ... seq quot: ( ... elt -- ... ? ) -- ... ? )
     [ find ] 2keep rot [
         [ 1 + ] 2dip find-from drop not