]> gitweb.factorcode.org Git - factor.git/commitdiff
make-string and make-list replace <> and [, ,]
authorSlava Pestov <slava@factorcode.org>
Thu, 11 Nov 2004 20:15:43 +0000 (20:15 +0000)
committerSlava Pestov <slava@factorcode.org>
Thu, 11 Nov 2004 20:15:43 +0000 (20:15 +0000)
32 files changed:
examples/factoroids.factor
examples/infix.factor
examples/mandel.factor
examples/timesheet.factor
library/ansi.factor
library/compiler/alien-types.factor
library/compiler/compile-all.factor
library/httpd/file-responder.factor
library/httpd/html-tags.factor
library/httpd/html.factor
library/httpd/http-common.factor
library/httpd/url-encoding.factor
library/init.factor
library/jedit/jedit-remote.factor
library/list-namespaces.factor
library/platform/jvm/sbuf.factor
library/platform/native/parse-syntax.factor
library/platform/native/prettyprint.factor
library/platform/native/profiler.factor
library/platform/native/unparser.factor
library/prettyprint.factor
library/random.factor
library/sbuf.factor
library/test/benchmark/sort.factor
library/test/benchmark/strings.factor
library/test/crashes.factor
library/test/lists/namespaces.factor
library/test/sbuf.factor
library/tools/debugger.factor
library/tools/image.factor
library/tools/listener.factor
library/vocabularies.factor

index b2ca0ee43d50f09f5ab14f7a16bfa92b0bd0578c..38d8c720cbde6c171cf0c3c787fd3bfa4ceafd61 100644 (file)
@@ -113,10 +113,6 @@ SYMBOL: enemy-shots
 
 ! The player's ship
 
-! Flags that can be set to move the ship
-SYMBOL: left
-SYMBOL: right
-
 TRAITS: ship
 M: ship draw ( actor -- )
     [
index f3d71f3cad9432ff4796635cdd43bd0a90f8923c..3d955174edc02ed2eeae9b6cfd6db46ab2247fd0 100644 (file)
@@ -21,7 +21,7 @@ DEFER: infix
 : infix ( list -- quot )
     #! Convert an infix expression (passed in as a list) to
     #! postfix.
-    [, 10 <vector> exprs set (infix) end ,] ;
+    [ 10 <vector> exprs set (infix) end ] make-list ;
 
 [ [ ] ] [ [ ] infix ] unit-test
 [ [ 1 ] ] [ [ 1 ] infix ] unit-test
index 3bb2d5731ff5cb6b57a8e6bfca3c61fc5d6ccb84..3f19b7aa866a7881f4df7ab65cbb9f9b32cc65ed 100644 (file)
@@ -39,12 +39,12 @@ USE: test
 : val 0.85 ;
 
 : <color-map> ( nb-cols -- map )
-    [,
+    [
         dup [
             360 * over succ / 360 / sat val
             hsv>rgb 1.0 scale-rgba ,
         ] times*
-    ,] list>vector nip ;
+    ] make-list list>vector nip ;
 
 : absq >rect swap sq swap sq + ;
 
index e3803a70c1e0d0f26629c0c305c524e735727558..a27d835f0a889402b6c2a31585d0810dbf706524 100644 (file)
@@ -34,7 +34,7 @@ USE: vectors
 
 : hh ( duration -- str ) 60 /i ;
 : mm ( duration -- str ) 60 mod unparse 2 digits ;
-: hh:mm ( millis -- str ) <% dup hh % ":" % mm % %> ;
+: hh:mm ( millis -- str ) [ dup hh , ":" , mm , ] make-list ;
 
 : print-entry ( duration description -- )
     dup write
index 4032bb6d9e6aace3f704831fb2fb58f81c3fd783..4b47426d77554917fd59818e942c39a6664d6e73 100644 (file)
@@ -68,13 +68,13 @@ USE: strings
     "\e[4" swap "m" cat3 ; inline
 
 : ansi-attrs ( style -- )
-    "bold"    over assoc [ bold % ] when
-    "ansi-fg" over assoc [ fg % ] when*
-    "ansi-bg" over assoc [ bg % ] when*
+    "bold"    over assoc [ bold , ] when
+    "ansi-fg" over assoc [ fg , ] when*
+    "ansi-bg" over assoc [ bg , ] when*
     drop ;
 
 : ansi-attr-string ( string style -- string )
-    <% ansi-attrs % reset % %> ;
+    [ ansi-attrs , reset , ] make-string ;
 
 : <ansi-stream> ( stream -- stream )
     #! Wraps the given stream in an ANSI stream. ANSI streams
index dadf09dc60d6bee783c5ac9a3ed9c6ffa0bc7293..37a3ceb34dfac48945d4f0a8beadfcb265d45c6d 100644 (file)
@@ -93,7 +93,7 @@ USE: words
     #! allocates a Factor heap-local instance of this structure.
     #! Used for C functions that expect you to pass in a struct.
     [ <local-alien> ] cons
-    <% "<" % "struct-name" get % ">" % %>
+    [ "<" , "struct-name" get , ">" , ] make-string
     "in" get create swap
     define-compound ;
 
index e397683b9c49b8332eee1bdc7041c7dd8b3ff373..ea8feefbd984bb3d7abc357afdeae61c4368d3b1 100644 (file)
@@ -111,7 +111,9 @@ SYMBOL: compilable-word-list
 : compilable-words ( -- list )
     #! Make a list of all words that can be compiled.
     reset-can-compile
-    [, [ dup can-compile? [ , ] [ drop ] ifte ] each-word ,]
+    [
+        [ dup can-compile? [ , ] [ drop ] ifte ] each-word
+    ] make-list
     reset-can-compile ;
 
 : cannot-compile ( word -- )
index 03f5883d0bbf32da25e022d9deaba9ec3ea5f3df..640e2d8f0b84cafd217e232c39ad7b848aceea49 100644 (file)
@@ -47,10 +47,10 @@ USE: unparser
     f>"" "doc-root" get swap cat2 ;
 
 : file-response ( mime-type length -- )
-    [,
+    [
         unparse "Content-Length" swons ,
         "Content-Type" swons ,
-    ,] "200 OK" response terpri ;
+    ] make-list "200 OK" response terpri ;
 
 : serve-static ( filename mime-type -- )
     over file-length file-response  "method" get "head" = [
index f9f28e2ebda30e330dfb76f023ac57103d644159..1df7cfe991ed557ba61d6aca00b979f12d371247 100644 (file)
@@ -69,7 +69,7 @@ USE: logic
 ! <a href= "http://" swap cat2 a> "click" write </a>
 !
 ! (url -- )
-! <a href= <% "http://" % % %> a> "click" write </a>
+! <a href= [ "http://" , , ] make-string a> "click" write </a>
 !
 ! Tags that have no 'closing' equivalent have a trailing tag/> form:
 !
@@ -78,7 +78,9 @@ USE: logic
 : attrs>string ( alist -- string )
     #! Convert the attrs alist to a string
     #! suitable for embedding in an html tag.
-    reverse <% [ dup car % "='" % cdr % "'" % ] each %> ;
+    reverse [
+        [ dup car , "='" , cdr , "'" , ] each
+    ] make-string ;
 
 : write-attributes ( n: namespace -- )    
     #! With the attribute namespace on the stack, get the attributes
@@ -163,13 +165,13 @@ USE: logic
 : def-for-html-word-</foo> ( name -- name quot )
     #! Return the name and code for the </foo> patterned
     #! word.    
-    <% "</" % % ">" % %> dup [ write ] cons ;
+    [ "</" , , ">" , ] make-string dup [ write ] cons ;
 
 : def-for-html-word-<foo/> ( name -- name quot )
     #! Return the name and code for the <foo/> patterned
     #! word.
-    <% "<" % dup % "/>" % %> swap
-    <% "<" % % ">" % %>
+    [ "<" , dup , "/>" , ] make-string swap
+    [ "<" , , ">" , ] make-string
     [ write ] cons ;
 
 : def-for-html-word-foo/> ( name -- name quot )
index 530ba06084ebfe705762f0a566beb7235833dc80..353ab06d422f6fe626dd0901c07f74168a8fd158 100644 (file)
@@ -58,33 +58,35 @@ USE: url-encoding
 : >hex-color ( triplet -- hex )
     [ >hex 2 digits ] map "#" swons cat ;
 
-: fg-css% ( color -- )
-    "color: " % >hex-color % "; " % ;
+: fg-css, ( color -- )
+    "color: " , >hex-color , "; " , ;
 
-: bold-css% ( flag -- )
-    [ "font-weight: bold; " % ] when ;
+: bold-css, ( flag -- )
+    [ "font-weight: bold; " , ] when ;
 
-: italics-css% ( flag -- )
-    [ "font-style: italic; " % ] when ;
+: italics-css, ( flag -- )
+    [ "font-style: italic; " , ] when ;
 
-: underline-css% ( flag -- )
-    [ "text-decoration: underline; " % ] when ;
+: underline-css, ( flag -- )
+    [ "text-decoration: underline; " , ] when ;
 
-: size-css% ( size -- )
-    "font-size: " % unparse % "; " % ;
+: size-css, ( size -- )
+    "font-size: " , unparse , "; " , ;
 
-: font-css% ( font -- )
-    "font-family: " % % "; " % ;
+: font-css, ( font -- )
+    "font-family: " , , "; " , ;
 
 : css-style ( style -- )
-    <% [
-        [ "fg"        fg-css% ]
-        [ "bold"      bold-css% ]
-        [ "italics"   italics-css% ]
-        [ "underline" underline-css% ]
-        [ "size"      size-css% ]
-        [ "font"      font-css% ]
-    ] assoc-apply %> ;
+    [
+        [
+            [ "fg"        fg-css, ]
+            [ "bold"      bold-css, ]
+            [ "italics"   italics-css, ]
+            [ "underline" underline-css, ]
+            [ "size"      size-css, ]
+            [ "font"      font-css, ]
+        ] assoc-apply
+    ] make-string ;
 
 : span-tag ( style quot -- )
     over css-style dup "" = [
@@ -101,7 +103,7 @@ USE: url-encoding
     ] when* "/" ?str-tail drop ;
 
 : file-link-href ( path -- href )
-    <% "/" % resolve-file-link url-encode % %> ;
+    [ "/" , resolve-file-link url-encode , ] make-string ;
 
 : file-link-tag ( style quot -- )
     over "file-link" swap assoc [
index 699a1af4b3c663dd3a0b2f49e18c2aa57c4f6c12..91a1c1a16692d093e58ed7606aa430cebbaed1ea 100644 (file)
@@ -80,9 +80,10 @@ USE: url-encoding
     "301 Moved Permanently" response terpri ;
 
 : directory-no/ ( -- )
-    <% "request" get % CHAR: / %
-    "raw-query" get [ CHAR: ? % % ] when*
-    %> redirect ;
+    [
+        "request" get , CHAR: / ,
+        "raw-query" get [ CHAR: ? , , ] when*
+    ] make-string redirect ;
 
 : header-line ( alist line -- alist )
     ": " split1 dup [ transp acons ] [ 2drop ] ifte ;
@@ -111,7 +112,7 @@ USE: url-encoding
 
 : log-user-agent ( alist -- )
     "User-Agent" swap assoc* [
-        unswons <% % ": " % % %> log
+        unswons [ , ": " , , ] make-string log
     ] when* ;
 
 : prepare-url ( url -- url )
index 4845f56c7b803874b2601e31c55dcc0ca3e55d26..0958c201c294f217e8078f4bc010bd082968af1b 100644 (file)
@@ -29,6 +29,7 @@ IN: url-encoding
 USE: combinators
 USE: errors
 USE: kernel
+USE: lists
 USE: logic
 USE: format
 USE: math
@@ -51,14 +52,14 @@ USE: unparser
         2drop
     ] [
         >r succ dup 2 + r> substring
-        catch-hex> [ >char % ] when*
+        catch-hex> [ >char , ] when*
     ] ifte ;
 
 : url-decode-% ( index str -- index str )
     2dup url-decode-hex >r 3 + r> ;
 
 : url-decode-+-or-other ( index str ch -- index str )
-    CHAR: + CHAR: \s replace % >r succ r> ;
+    CHAR: + CHAR: \s replace , >r succ r> ;
 
 : url-decode-iter ( index str -- )
     2dup str-length >= [
@@ -72,4 +73,4 @@ USE: unparser
     ] ifte ;
 
 : url-decode ( str -- str )
-    <% 0 swap url-decode-iter %> ;
+    [ 0 swap url-decode-iter ] make-string ;
index e3759028dea9dd61656bc5ed1391653e27bfb7e7..03eda3e8d83826c014a9f97e5dd849f05e50d616 100644 (file)
@@ -53,7 +53,7 @@ USE: words
 : run-user-init ( -- )
     #! Run user init file if it exists
     "user-init" get [
-        <% "~" get % "/" get % ".factor-" % "rc" % %>
+        [ "~" get , "/" get , ".factor-" , "rc" , ] make-string
         ?run-file
     ] when ;
 
index 4cc0022c3b55934ea0d5496a1d7618e776d23f41..feacc3006b38e147a8d1c1f44ef41de0ed1e0e25 100644 (file)
@@ -48,24 +48,25 @@ USE: unparser
         read parse-number
     ] with-stream ;
 
-: bool% ( ? -- str )
-    "true" "false" ? % ;
+: bool, ( ? -- str )
+    "true" "false" ? , ;
 
-: list>bsh-array% ( list -- code )
-    "new String[] {" %
-    [ unparse % "," % ] each
-    "null}" % ;
+: list>bsh-array, ( list -- code )
+    "new String[] {" ,
+    [ unparse , "," , ] each
+    "null}" , ;
 
 : make-jedit-request ( files dir params -- code )
     [
-        <%
-        "EditServer.handleClient(" %
-        "restore" get bool% "," %
-        "newView" get bool% "," %
-        "newPlainView" get bool% "," %
-        ( If the dir is not set, we don't want to send f )
-        dup [ unparse ] [ drop "null" ] ifte % "," %
-        list>bsh-array% ");\n" % %>
+        [
+            "EditServer.handleClient(" ,
+            "restore" get bool, "," ,
+            "newView" get bool, "," ,
+            "newPlainView" get bool, "," ,
+            ( If the dir is not set, we don't want to send f )
+            dup [ unparse ] [ drop "null" ] ifte , "," ,
+            list>bsh-array, ");\n" ,
+        ] make-string
     ] bind ;
 
 : send-jedit-request ( request -- )
index c8b1bd371a86b67873705e0d4e84660f21d05980..3cd6fb88335298eed6ab4685371fe49d9cd5427e 100644 (file)
@@ -54,9 +54,16 @@ USE: stack
     #! variable if it is not already contained in the list.
     tuck get unique put ;
 
-: [, ( -- )
-    #! Begin constructing a list.
-    <namespace> >n f "list-buffer" set ;
+: make-rlist ( quot -- list )
+    #! Call a quotation. The quotation can call , to prepend
+    #! objects to the list that is returned when the quotation
+    #! is done.
+    [ "list-buffer" off call "list-buffer" get ] with-scope ;
+
+: make-list ( quot -- list )
+    #! Return a list whose entries are in the same order that ,
+    #! was called.
+    make-rlist reverse ;
 
 : , ( obj -- )
     #! Append an object to the currently constructing list.
@@ -66,7 +73,3 @@ USE: stack
     #! Append an object to the currently constructing list, only
     #! if the object does not already occur in the list.
     "list-buffer" unique@ ;
-
-: ,] ( -- list )
-    #! Finish constructing a list and push it on the stack.
-    "list-buffer" get reverse n> drop ;
index e82c0e9acc0226ce8074f8561dbab89f410ddb52..d4151a2378e62c433fba0be2ca2c85139aafd798 100644 (file)
@@ -59,6 +59,8 @@ USE: stack
     #! Destructively reverse a string buffer.
     [ ] "java.lang.StringBuffer" "reverse" jinvoke drop ;
 
-DEFER: str>sbuf
+: str>sbuf ( str -- sbuf )
+    dup str-length <sbuf> tuck sbuf-append ;
+
 : str-reverse ( str -- str )
     str>sbuf dup sbuf-reverse sbuf>str ;
index 9351a32196c0d403c470375496d45bd8a1797921..9f0c1c7fa1b1539a1a3424dc21956fb12336e78f 100644 (file)
@@ -169,13 +169,14 @@ IN: syntax
     next-ch dup CHAR: " = [
         drop
     ] [
-        parse-ch % parse-string
+        parse-ch , parse-string
     ] ifte ;
 
 : "
     #! Note the ugly hack to carry the new value of 'pos' from
-    #! the <% %> scope up to the original scope.
-    <% parse-string "col" get %> swap "col" set parsed ; parsing
+    #! the make-string scope up to the original scope.
+    [ parse-string "col" get ] make-string
+    swap "col" set parsed ; parsing
 
 ! Complex literal
 : #{
index cfa2e56f505d40ce04bb078327ee7bfbcbfa00bf..02cf0d573e2e628571f5b84aa61f51b63d0082d7 100644 (file)
@@ -39,7 +39,7 @@ USE: words
 : stack-effect. ( word -- )
     stack-effect [
         " " write
-        <% CHAR: ( % % CHAR: ) % %> prettyprint-comment
+        [ CHAR: ( , , CHAR: ) , ] make-string prettyprint-comment
     ] when* ;
 
 : documentation. ( indent word -- indent )
index 33c6a597658db28f6a8521f725d5ca1fa374c9cc..d996448f54e8e1d6175b5741ab3f5c6ac30120f6 100644 (file)
@@ -55,7 +55,7 @@ SYMBOL: only-top
 
 : call-counts. ( -- )
     #! Print word/call count pairs.
-    [, [ call-count, ] each-word ,] counts. ;
+    [ [ call-count, ] each-word ] make-list counts. ;
 
 : profile-depth ( -- n )
     only-top get [ -1 ] [ callstack vector-length ] ifte ;
@@ -76,7 +76,7 @@ SYMBOL: only-top
 
 : allot-counts. ( -- alist )
     #! Print word/allot count pairs.
-    [, [ allot-count, ] each-word ,] counts. ;
+    [ [ allot-count, ] each-word ] make-list counts. ;
 
 : allot-profile ( quot -- )
     #! Execute a quotation with the memory profiler enabled.
index 8c724811131318767257828308e514ef9e2a8279..9a38452b61e35e82de830e60fafd3b8f8ed5b559 100644 (file)
@@ -42,23 +42,22 @@ USE: words
 : >digit ( n -- ch )
     dup 10 < [ CHAR: 0 + ] [ 10 - CHAR: a + ] ifte ;
 
-: integer% ( num radix -- )
-    tuck /mod >digit % dup 0 > [
-        swap integer%
+: integer, ( num radix -- )
+    tuck /mod >digit , dup 0 > [
+        swap integer,
     ] [
         2drop
     ] ifte ;
 
-: integer- ( num -- num )
-    dup 0 < [ "-" % neg ] when ;
-
 : >base ( num radix -- string )
     #! Convert a number to a string in a certain base.
-    <% over 0 < [
-        swap neg swap integer% CHAR: - %
-    ] [
-        integer%
-    ] ifte reverse%> ;
+    [
+        over 0 < [
+            swap neg swap integer, CHAR: - ,
+        ] [
+            integer,
+        ] ifte
+    ] make-rstring ;
 
 : >dec ( num -- string ) 10 >base ;
 : >bin ( num -- string ) 2 >base ;
@@ -68,13 +67,22 @@ USE: words
 DEFER: unparse
 
 : unparse-ratio ( num -- str )
-    <% dup
-    numerator unparse %
-    CHAR: / %
-    denominator unparse % %> ;
+    [
+        dup
+        numerator unparse ,
+        CHAR: / ,
+        denominator unparse ,
+    ] make-string ;
 
 : unparse-complex ( num -- str )
-    >rect <% "#{ " % swap unparse % " " % unparse % " }" % %> ;
+    [
+        "#{ " ,
+        dup
+        real unparse ,
+        " " ,
+        imaginary unparse ,
+        " }" ,
+    ] make-string ;
 
 : ch>ascii-escape ( ch -- esc )
     [
@@ -100,7 +108,9 @@ DEFER: unparse
     ] unless ;
 
 : unparse-str ( str -- str )
-    <% CHAR: " % [ unparse-ch % ] str-each CHAR: " % %> ;
+    [
+        CHAR: " , [ unparse-ch , ] str-each CHAR: " ,
+    ] make-string ;
 
 : unparse-word ( word -- str )
     word-name dup "#<unnamed>" ? ;
@@ -113,11 +123,13 @@ DEFER: unparse
 : unparse-float ( float -- str ) (unparse-float) fix-float ;
 
 : unparse-unknown ( obj -- str )
-    <% "#<" %
-    dup type type-name %
-    " @ " % 
-    address unparse %
-    ">" % %> ;
+    [
+        "#<" ,
+        dup type type-name ,
+        " @ " , 
+        address unparse ,
+        ">" ,
+    ] make-string ;
 
 : unparse-t drop "t" ;
 : unparse-f drop "f" ;
index b5aba002dafc384d3c47df585641bb73123512b2..370aa2d179f10b5d86dec99384b795dd5684fe06 100644 (file)
@@ -144,12 +144,12 @@ DEFER: prettyprint*
     trim-newline "comments" style write-attr ;
 
 : word-link ( word -- link )
-    <%
-    "vocabularies'" %
-    dup word-vocabulary %
-    "'" %
-    word-name %
-    %> ;
+    [
+        "vocabularies'" ,
+        dup word-vocabulary ,
+        "'" ,
+        word-name ,
+    ] make-string ;
 
 : word-actions ( -- list )
     [
@@ -194,7 +194,7 @@ DEFER: prettyprint*
     0 swap prettyprint* drop terpri ;
 
 : vocab-link ( vocab -- link )
-    <% "vocabularies'" % % %> ;
+    "vocabularies'" swap cat2 ;
 
 : vocab-attrs ( word -- attrs )
     vocab-link "object-link" default-style acons ;
index 1e0c28ec17b9a6b9a5867b0d40d4c07dcc9b44bb..c762b15b4b74be2d9d30b4415a71532299905186 100644 (file)
@@ -84,7 +84,7 @@ USE: stack
     #! Returns a random subset of the given list of comma pairs.
     #! The car of each pair is a probability, the cdr is the
     #! item itself. Only the cdr of the comma pair is returned.
-    [,
+    [
         [ car+ ] keep ( probabilitySum list )
         [
             >r 1 over random-int r> ( probabilitySum probability elem )
@@ -93,4 +93,4 @@ USE: stack
             > ( probabilitySum elemd boolean )
             [ drop ] [ , ] ifte
         ] each drop
-    ,] ;
+    ] make-list ;
index 809558ce49d29d32c6417c1df024d0ad1c66d0d0..f0181f89da33709496391c29f435608db5bfaaa9 100644 (file)
@@ -34,34 +34,21 @@ USE: namespaces
 USE: strings
 USE: stack
 
-: str>sbuf ( str -- sbuf )
-    dup str-length <sbuf> tuck sbuf-append ;
+: make-string ( quot -- string )
+    #! Call a quotation. The quotation can call , to prepend
+    #! objects to the list that is returned when the quotation
+    #! is done.
+    make-list cat ;
 
-: string-buffer-size 80 ;
-
-: <% ( -- )
-    #! Begins constructing a string.
-    <namespace> >n string-buffer-size <sbuf>
-    "string-buffer" set ;
-
-: % ( str -- )
-    #! Append a string to the construction buffer.
-    "string-buffer" get sbuf-append ;
-
-: %> ( -- str )
-    #! Ends construction and pushes the constructed text on the
-    #! stack.
-    "string-buffer" get sbuf>str n> drop ;
-
-: reverse%> ( -- str )
-     #! Ends construction and pushes the *reversed*, constructed
-     #! text on the stack.
-     "string-buffer" get dup sbuf-reverse sbuf>str n> drop ;
+: make-rstring ( quot -- string )
+    #! Return a string whose entries are in the same order that ,
+    #! was called.
+    make-rlist cat ;
 
 : fill ( count char -- string )
     #! Push a string that consists of the same character
     #! repeated.
-    <% swap [ dup % ] times drop %> ;
+    [ swap [ dup , ] times drop ] make-string ;
 
 : str-map ( str code -- str )
     #! Apply a quotation to each character in the string, and
@@ -88,7 +75,7 @@ USE: stack
 : split ( string split -- list )
     #! Split the string at each occurrence of split, and push a
     #! list of the pieces.
-    [, 0 -rot (split) ,] ;
+    [ 0 -rot (split) ] make-list ;
 
 : split-n-advance substring , >r tuck + swap r> ;
 : split-n-finish nip dup str-length swap substring , ;
@@ -102,4 +89,4 @@ USE: stack
 
 : split-n ( n str -- list )
     #! Split a string into n-character chunks.
-    [, 0 -rot (split-n) ,] ;
+    [ 0 -rot (split-n) ] make-list ;
index e5464bad9bd1f64a2c20480d1b8f075182d1e9db..327b1ce5d8faaaf2ee23202f8bd8269caad7275c 100644 (file)
@@ -5,4 +5,4 @@ USE: random
 USE: stack
 USE: test
 
-[ ] [ [, 100000 [ 0 10000 random-int , ] times ,] num-sort drop ] unit-test
+[ ] [ [ 100000 [ 0 10000 random-int , ] times ] make-list num-sort drop ] unit-test
index 5dd7df6c306ddd05fe3d17d2a8a40739fda8ec2a..67a1001b5cbcf4bf8ecb969dc400d59abad4e42e 100644 (file)
@@ -3,12 +3,13 @@ USE: strings
 USE: math
 USE: combinators
 USE: test
+USE: lists
 
 ! http://inferno.bell-labs.com/cm/cs/who/bwk/interps/pap.html
 
 : string-step ( n str -- )
     2dup str-length > [
-        dup <% "123" % % "456" % % "789" % %>
+        dup [ "123" , , "456" , , "789" , ] make-string
         dup dup str-length 2 /i 0 transp substring
         swap dup str-length 2 /i succ 1 transp substring cat2
         string-step
index b03abf466770c9abf26278423da552b51f6126b8..cf1d918046c1d17e83cabf633dbed8f892d8b67b 100644 (file)
@@ -22,10 +22,6 @@ USE: lists
     [ drop ] [ drop ] catch
 ] keep-datastack
 
-"hello" str>sbuf "x" set
-[ -5 "x" get set-sbuf-length ] [ drop ] catch
-[ "x" get sbuf>str drop ] [ drop ] catch
-
 10 <vector> "x" set
 [ -2 "x" get set-vector-length ] [ drop ] catch
 [ "x" get vector-clone drop ] [ drop ] catch
index 2bca360fa548eb06e7196d45de1da9802bde45b1..fdeaf07dbb2e2f729ebb68a5bccf716b4b52ff90 100644 (file)
@@ -33,8 +33,8 @@ USE: test
 ] unit-test
 
 [ [ "xyz" #{ 3 2 } 1/5 [ { } ] ] ] [
-    [, "xyz" , "xyz" unique,
+    [ "xyz" , "xyz" unique,
     #{ 3 2 } , #{ 3 2 } unique,
     1/5 , 1/5 unique,
-    [, { } unique, ,] , ,]
+    [ { } unique, ] make-list , ] make-list
 ] unit-test
index 58c7ff3a153549a116e47298efe4f32096377b52..6b4e1ac4e0239d8bfcc447391c748833116d34eb 100644 (file)
@@ -9,10 +9,6 @@ USE: stack
 USE: strings
 USE: test
 
-[ t ] [ "Foo" str>sbuf "Foo" str>sbuf = ] unit-test
-[ f ] [ "Foo" str>sbuf "Foob" str>sbuf = ] unit-test
-[ f ] [ 34 "Foo" str>sbuf = ] unit-test
-
 [ "Hello" ] [
     100 <sbuf> "buf" set
     "Hello" "buf" get sbuf-append
@@ -20,8 +16,3 @@ USE: test
     "World" "buf-clone" get sbuf-append
     "buf" get sbuf>str
 ] unit-test
-
-[ t ] [
-    "Hello world" str>sbuf hashcode
-    "Hello world" hashcode =
-] unit-test
index 5f339c78cd47fe8e6d22b4a13f59ce3b12ba2eeb..3b5eda2a92df2741a890d60420b63c0e11803813 100644 (file)
@@ -29,6 +29,7 @@ IN: errors
 USE: combinators
 USE: continuations
 USE: kernel
+USE: lists
 USE: logic
 USE: namespaces
 USE: prettyprint
@@ -41,15 +42,15 @@ USE: unparser
     "ERROR: " write error. ;
 
 : parse-dump ( error -- )
-    <%
-    "error-file" get [ "<interactive>" ] unless* % ":" %
-    "error-line-number" get [ 1 ] unless* unparse % ": " %
-    %> write
+    [
+        "error-file" get [ "<interactive>" ] unless* , ":" ,
+        "error-line-number" get [ 1 ] unless* unparse , ": " ,
+    ] make-string write
     error.
     
     "error-line" get print
     
-    <% "error-col" get " " fill % "^" % %> print ;
+    [ "error-col" get " " fill , "^" , ] make-string print ;
 
 : in-parser? ( -- ? )
     "error-line" get "error-col" get and ;
index beaa71c3545c993fcba4cc6ac8a558365914b914..e361002b38e3763a7fa167427fb06ae0fd4db873 100644 (file)
@@ -274,13 +274,11 @@ DEFER: '
     (vocabulary) set-hash ;
 
 : 'plist ( word -- plist )
-    [,
-
-    dup word-name "name" swons ,
-    dup word-vocabulary "vocabulary" swons ,
-    "parsing" word-property [ t "parsing" swons , ] when
-
-    ,] ' ;
+    [
+        dup word-name "name" swons ,
+        dup word-vocabulary "vocabulary" swons ,
+        "parsing" word-property [ t "parsing" swons , ] when
+    ] make-list ' ;
 
 : (worddef,) ( word primitive parameter -- )
     ' >r >r dup (word+) dup 'plist >r
index 51dacad74bcfc68e9b4d25fdd2cd602137421c3e..93b7feb92068c955443154c13b9d4627e3717c98 100644 (file)
@@ -44,8 +44,12 @@ USE: unparser
 USE: vectors
 
 : print-banner ( -- )
-    <% "This is " % java? [ "JVM " % ] when
-    native? [ "native " % ] when "Factor " % version % %> print
+    [
+        "This is " ,
+        java? [ "JVM " , ] when
+        native? [ "native " , ] when
+        "Factor " , version ,
+    ] make-string print
     "Copyright (C) 2003, 2004 Slava Pestov" print
     "Copyright (C) 2004 Chris Double" print
     "Type ``exit'' to exit, ``help'' for help." print ;
index 81f431e888fea31ed5634ddb530806de2f29200a..d71ff0e2c7be996da12e69b01d714daf24fd8056 100644 (file)
@@ -35,16 +35,20 @@ USE: strings
 
 : vocabs ( -- list )
     #! Push a list of vocabularies.
-    global [ "vocabularies" get [ vars ] bind ] bind ;
+    global [ "vocabularies" get [ vars str-sort ] bind ] bind ;
 
 : vocab ( name -- vocab )
     #! Get a vocabulary.
     global [ "vocabularies" get get* ] bind ;
 
+: word-sort ( list -- list )
+    #! Sort a list of words by name.
+    [ swap word-name swap word-name str-lexi> ] sort ;
+
 : words ( vocab -- list )
     #! Push a list of all words in a vocabulary.
     #! Filter empty slots.
-    vocab [ values ] bind [ ] subset ;
+    vocab [ values ] bind [ ] subset word-sort ;
 
 : init-search-path ( -- )
     ! For files