]> gitweb.factorcode.org Git - factor.git/commitdiff
sequences: Add 1surround which is dup surround
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 12 Jan 2022 01:14:18 +0000 (19:14 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 12 Jan 2022 02:15:01 +0000 (20:15 -0600)
add >string-list

15 files changed:
basis/escape-strings/escape-strings.factor
basis/escape-strings/ui/ui.factor
basis/ftp/server/server.factor
basis/io/launcher/windows/windows.factor
basis/prettyprint/backend/backend.factor
core/sequences/sequences.factor
core/strings/parser/parser.factor
extra/crypto/passwd-md5/passwd-md5.factor
extra/html/parser/utils/utils.factor
extra/images/testing/testing.factor
extra/managed-server/chat/chat.factor
extra/modern/html/html.factor
extra/rosetta-code/sierpinski-triangle/sierpinski-triangle.factor
extra/sequences/extras/extras.factor
extra/tools/grep/grep.factor

index 4c0f4b762eb815f957d9041c19085ede5977d2eb..89de4c8da3e68e82338729d7f9d9760895cdc98c 100644 (file)
@@ -49,7 +49,7 @@ IN: escape-strings
     [ nip ] [ drop length ] if ;
 
 : surround-by-brackets ( str delim -- str' )
-    [ "[" dup surround ] [ "]" dup surround ] bi surround ;
+    [ "[" 1surround ] [ "]" 1surround ] bi surround ;
 
 : surround-by-equals-brackets ( str n -- str' )
     CHAR: = <repetition> surround-by-brackets ;
index f24de3dc81768af6480546d7f896ddde2a9764ab..fb685d0da63242010d4795ecc80d655ddb79c419 100644 (file)
@@ -25,11 +25,8 @@ M: escape-string-editor model-changed
         [ quot>> call( str -- str' ) ] [ set-editor-string ] bi
     ] [ call-next-method ] if ;
 
-: cake ( string delim -- string' )
-    dup surround ; inline
-
 : containerize ( string tag open-delim close-delim -- string' )
-    overd [ cake ] 2bi@ surround ;
+    overd [ 1string ] 2bi@ surround ;
 
 : checksum-escape-string ( string checksum -- string' )
     [ drop ]
index e39f4d4f4809a84b5fdd3bb243e4e3354185e852..04e019eefdccb83d08e81c8c34a5d40e8d42a5cc 100644 (file)
@@ -133,7 +133,7 @@ ERROR: type-error type ;
 
 : handle-PWD ( obj -- )
     drop
-    display-directory "\"" dup surround 257 server-response ;
+    display-directory "\"" 1surround 257 server-response ;
 
 : handle-SYST ( obj -- )
     drop
index 1ad2122d6b7f7f04029ebb0c61106c568f1893f3..7829ec5d8d99730b8d0db8d2626e4c62f5b99ddf 100644 (file)
@@ -82,7 +82,7 @@ TUPLE: CreateProcess-args
 : escape-argument ( str -- newstr )
     escape-double-quote
     CHAR: \s over member? [
-        fix-trailing-backslashes "\"" dup surround
+        fix-trailing-backslashes "\"" 1surround
     ] when ;
 
 : join-arguments ( args -- cmd-line )
index 56200756c0160f344f208b009071772bc7448e16..c9186556971e6fd0d0ff9c20955635e5b93758ed 100644 (file)
@@ -157,7 +157,7 @@ M: pathname pprint*
 : check-recursion ( obj quot: ( obj -- ) -- )
     nesting-limit? [
         drop
-        [ class-of name>> "~" dup surround ] keep present-text
+        [ class-of name>> "~" 1surround ] keep present-text
     ] [
         over recursion-check get member-eq? [
             drop "~circularity~" swap present-text
index d6d2d3008ce7ef7830abcdc140df6375a35e197f..7d20148de9b2b19ce121cfe19fa346c370c94075 100644 (file)
@@ -380,6 +380,10 @@ PRIVATE>
 
 : surround ( seq1 seq2 seq3 -- newseq ) over surround-as ; inline
 
+: 1surround-as ( seq1 seq2 exemplar  -- newseq ) dupd surround-as ; inline
+
+: 1surround ( seq1 seq2 -- newseq ) over 1surround-as ; inline
+
 : glue-as ( seq1 seq2 seq3 exemplar -- newseq ) swapd 3append-as ; inline
 
 : glue ( seq1 seq2 seq3 -- newseq ) pick glue-as ; inline
index 0fe17af62722770ccd246a6ab58dcb9a19601846..9e70223671ac6e04d6961106519214ec94c3da98 100644 (file)
@@ -124,7 +124,7 @@ DEFER: (parse-string)
         dup current-char forbid-tab {
             { CHAR: \s [ advance-char ] }
             { f [ drop ] }
-            [ "[space]" swap 1string "'" dup surround unexpected ]
+            [ "[space]" swap 1string "'" 1surround unexpected ]
         } case drop
     ] if ;
 
index 0f17e8459c2a807a56388ec4e439cd998c1e3496..d256311a0ac494249b78104ff977e6f543789c5b 100644 (file)
@@ -18,7 +18,7 @@ PRIVATE>
 
 :: passwd-md5 ( magic salt password -- bytes )
     password magic salt 3append
-    salt password dup surround md5 checksum-bytes
+    salt password 1surround md5 checksum-bytes
     password length
     [ 16 / ceiling swap <repetition> concat ] keep
     head-slice append
@@ -42,7 +42,7 @@ PRIVATE>
     11 final nth 2 to64 3append ;
 
 : parse-shadow-password ( string -- magic salt password )
-    "$" split harvest first3 [ "$" dup surround ] 2dip ;
+    "$" split harvest first3 [ "$" 1surround ] 2dip ;
 
 : authenticate-password ( shadow password -- ? )
     '[ parse-shadow-password drop _ passwd-md5 ] keep = ;
index ddb7a062b3b75dc6c5ec6cd8707c9c62ec6b2fc0..982820e33839e7f3ee1d417843a5c09422e4c40f 100644 (file)
@@ -6,9 +6,9 @@ IN: html.parser.utils
 : trim1 ( seq ch -- newseq )
     [ [ ?head-slice drop ] [ ?tail-slice drop ] bi ] keepd like ;
 
-: single-quote ( str -- newstr ) "'" dup surround ;
+: single-quote ( str -- newstr ) "'" 1surround ;
 
-: double-quote ( str -- newstr ) "\"" dup surround ;
+: double-quote ( str -- newstr ) "\"" 1surround ;
 
 : quote ( str -- newstr )
     CHAR: ' over member?
index 94a68a96e087075de4df8b15675c5f296b80cce8..574533aa7af2ad6fc488297fed05c1af4f879d32 100644 (file)
@@ -27,7 +27,7 @@ PRIVATE>
     [ image. ] with-matching-files ;
 
 : ls ( dirpath extension -- )
-    [ "\"" dup surround print ] with-matching-files ;
+    [ "\"" 1surround print ] with-matching-files ;
 
 : save-as-reference-image ( path -- )
     [ load-image ] [ fig-name ] bi
index c425890c402bc05e8a921798157ea8763fd70793..74aa37f4b0a448a611d1ab12bc156c0cf314b371 100644 (file)
@@ -120,7 +120,7 @@ M: chat-server handle-client-join
 M: chat-server handle-client-disconnect
     [
         line-beginning username " has quit  "
-        client object>> dup [ "\"" dup surround ] when
+        client object>> dup [ "\"" 1surround ] when
     ] "" append-outputs-as send-everyone ;
 
 M: chat-server handle-already-logged-in
index 483eaf64ff5269b05c88d6dd4be2e1111cd4ebe4..cbae2fa824e39619717b5c9f49d2aa456f0061ac 100644 (file)
@@ -180,8 +180,8 @@ GENERIC: write-html ( tag -- )
 
 : >value ( obj -- string )
     {
-        { [ dup squote? ] [ payload>> "'" dup surround ] }
-        { [ dup dquote? ] [ payload>> "\"" dup surround ] }
+        { [ dup squote? ] [ payload>> "'" 1surround ] }
+        { [ dup dquote? ] [ payload>> "\"" 1surround ] }
         [ ]
     } cond ;
 
index c2ba8f48720b0be5c56b3589bdd162dfbaa17da8..d37204298814d9db4e9b1cd9b6267bb4dfa8bb1a 100644 (file)
@@ -27,7 +27,7 @@ IN: rosetta-code.sierpinski-triangle
 !        * * * * * * * * * * * * * * * *
 
 : iterate-triangle ( triange spaces -- triangle' )
-    [ [ dup surround ] curry map ]
+    [ [ 1surround ] curry map ]
     [ drop [ dup " " glue ] map ] 2bi append ;
 
 : (sierpinski) ( triangle spaces n -- triangle' )
index 9259b64a1dce7485f52d7af2a651bc99ab4e112c..2c9a2d7ce02678ff13bc6d5e5a49fe5602518853 100644 (file)
@@ -351,6 +351,9 @@ PRIVATE>
 : unsurround ( newseq seq2 seq3 -- seq1 )
    [ ?head drop ] [ ?tail drop ] bi* ;
 
+: >string-list ( seq -- seq' )
+    [ "\"" 1surround ] map "," join ;
+
 : one? ( ... seq quot: ( ... elt -- ... ? ) -- ... ? )
     [ find ] 2keep rot [
         [ 1 + ] 2dip find-from drop not
index e600e0a4e111dae9720968a230e2a39fbed53303..6c82a4b74e00635453ca40a653341a54f57cce0e 100644 (file)
@@ -21,7 +21,7 @@ IN: tools.grep
     command-line get [
         grep-usage
     ] [
-        unclip ".*" dup surround <regexp> swap [
+        unclip ".*" 1surround <regexp> swap [
             grep-lines
         ] [
             [ grep-file ] with each