]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor
authorDoug Coleman <doug.coleman@gmail.com>
Sun, 7 Sep 2008 04:58:32 +0000 (23:58 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 7 Sep 2008 04:58:32 +0000 (23:58 -0500)
79 files changed:
basis/base64/base64.factor
basis/channels/channels.factor
basis/checksums/sha1/sha1.factor
basis/compiler/generator/iterator/iterator.factor
basis/compiler/tree/checker/checker.factor
basis/compiler/tree/cleanup/cleanup.factor
basis/compiler/tree/escape-analysis/branches/branches.factor
basis/compiler/tree/normalization/normalization.factor
basis/compiler/tree/propagation/info/info.factor
basis/compiler/tree/tree.factor
basis/db/postgresql/lib/lib.factor
basis/db/types/types.factor
basis/debugger/debugger.factor
basis/farkup/farkup.factor
basis/fry/fry.factor
basis/furnace/actions/actions.factor
basis/furnace/auth/features/edit-profile/edit-profile.factor
basis/furnace/furnace.factor
basis/help/help.factor
basis/help/lint/lint.factor
basis/help/markup/markup.factor
basis/hints/hints.factor
basis/html/streams/streams.factor
basis/inspector/inspector.factor
basis/io/sockets/sockets.factor
basis/lcs/diff2html/diff2html.factor
basis/locals/locals.factor
basis/logging/insomniac/insomniac.factor
basis/models/history/history.factor
basis/multiline/multiline.factor
basis/prettyprint/prettyprint.factor
basis/random/random.factor
basis/stack-checker/backend/backend.factor
basis/stack-checker/branches/branches.factor
basis/stack-checker/errors/errors.factor
basis/stack-checker/transforms/transforms.factor
basis/tools/deploy/config/config.factor
basis/tools/test/test.factor
basis/tools/vocabs/browser/browser.factor
basis/tools/vocabs/vocabs.factor
basis/tools/walker/walker.factor
basis/ui/gestures/gestures.factor
basis/ui/tools/listener/listener.factor
basis/unicode/breaks/breaks.factor
basis/windows/com/wrapper/wrapper.factor
basis/xml/tokenize/tokenize.factor
basis/xml/writer/writer.factor
core/classes/algebra/algebra.factor
core/classes/builtin/builtin.factor
core/classes/intersection/intersection.factor
core/classes/tuple/parser/parser.factor
core/classes/union/union.factor
core/destructors/destructors.factor
core/io/files/files.factor
core/io/streams/string/string.factor
core/sequences/sequences-docs.factor
core/sequences/sequences.factor
extra/backtrack/backtrack.factor
extra/cords/cords.factor
extra/game-input/backend/iokit/iokit.factor
extra/html/parser/parser.factor
extra/inverse/inverse.factor
extra/irc/ui/commandparser/commandparser.factor
extra/irc/ui/ui.factor
extra/koszul/koszul.factor
extra/math/polynomials/polynomials.factor
extra/math/primes/factors/factors.factor
extra/math/text/english/english.factor
extra/money/money.factor
extra/multi-methods/multi-methods.factor
extra/pack/pack.factor
extra/porter-stemmer/porter-stemmer.factor
extra/project-euler/079/079.factor
extra/reports/noise/noise.factor
extra/sequences/lib/lib-docs.factor
extra/sequences/lib/lib-tests.factor
extra/sequences/lib/lib.factor
extra/units/units.factor
extra/xml/syntax/syntax.factor

index 3bf1a527ea40937514f31db1a075b965537e79b7..747cfa1128c8fc74f5423c754a32a928b1cc34ba 100644 (file)
@@ -36,7 +36,7 @@ PRIVATE>
     #! pad string with = when not enough bits
     dup length dup 3 mod - cut
     [ 3 <groups> [ encode3 ] map concat ]
-    [ dup empty? [ drop "" ] [ >base64-rem ] if ]
+    [ [ "" ] [ >base64-rem ] if-empty ]
     bi* append ;
 
 : base64> ( base64 -- str )
index 545d8a0e1d08b1f6a74735201fbcc7462d464765..9b8c418634183d6cae0c4b9093e4461874354f22 100755 (executable)
@@ -33,10 +33,10 @@ PRIVATE>
 
 M: channel to ( value channel -- )
     dup receivers>>
-    dup empty? [ drop dup wait to ] [ nip (to) ] if ;
+    [ dup wait to ] [ nip (to) ] if-empty ;
 
 M: channel from ( channel -- value )
     [
         notify senders>>
-        dup empty? [ drop ] [ (from) ] if
+        [ (from) ] unless-empty
     ] curry "channel receive" suspend ;
index 0ddb429b285125367f2272d5affd22a572b1b49f..6aa2cfa2eb64cbf2405aa8055790c67c90dca107 100755 (executable)
@@ -120,7 +120,7 @@ M: sha1 checksum-stream ( stream -- sha1 )
 
 : seq>2seq ( seq -- seq1 seq2 )
     #! { abcdefgh } -> { aceg } { bdfh }
-    2 group flip dup empty? [ drop { } { } ] [ first2 ] if ;
+    2 group flip [ { } { } ] [ first2 ] if-empty ;
 
 : 2seq>seq ( seq1 seq2 -- seq )
     #! { aceg } { bdfh } -> { abcdefgh }
index 473d59c3e45f20d730482a67fe30856e513999e7..203216b1c05ab1e2939f2b80978c9043d4085d5d 100644 (file)
@@ -28,18 +28,18 @@ DEFER: (tail-call?)
     [ first #phi? ] [ rest-slice (tail-call?) ] bi and ;
 
 : (tail-call?) ( cursor -- ? )
-    dup empty? [ drop t ] [
+    [ t ] [
         [ first [ #return? ] [ #terminate? ] bi or ]
         [ tail-phi? ]
         bi or
-    ] if ;
+    ] if-empty ;
 
 : tail-call? ( -- ? )
     node-stack get [
         rest-slice
-        dup empty? [ drop t ] [
+        [ t ] [
             [ (tail-call?) ]
             [ first #terminate? not ]
             bi and
-        ] if
+        ] if-empty
     ] all? ;
index 0f81e3805a9c7ad4e732638e2cdaaca1fe87004c..b712a6e354accd0e92fd1b7cc7aa2ae0025f2551 100644 (file)
@@ -32,7 +32,7 @@ M: #shuffle check-node*
 M: #copy check-node* inputs/outputs 2array check-lengths ;
 
 : check->r/r> ( node -- )
-    inputs/outputs dup empty? [ 2drop ] [ 2array check-lengths ] if ;
+    inputs/outputs [ drop ] [ 2array check-lengths ] if-empty ;
 
 M: #>r check-node* check->r/r> ;
 
index cc5f0619cd33d3d1a75cc059fe450b8bd46934eb..44a6a11802d28ecf6cc464f301c32d6ee90a4b4d 100644 (file)
@@ -37,8 +37,8 @@ GENERIC: cleanup* ( node -- node/nodes )
     [ cleanup* ] map flatten ;
 
 : cleanup-folding? ( #call -- ? )
-    node-output-infos dup empty?
-    [ drop f ] [ [ literal?>> ] all? ] if ;
+    node-output-infos
+    [ f ] [ [ literal?>> ] all? ] if-empty ;
 
 : cleanup-folding ( #call -- nodes )
     #! Replace a #call having a known result with a #drop of its
index c44861e45f15c61f16ca5361e39bee444f5b44e9..b728e9a1ba4b597def7482835d831f3e8b476303 100644 (file)
@@ -15,7 +15,7 @@ M: #branch escape-analysis*
 
 : (merge-allocations) ( values -- allocation )
     [
-        dup [ allocation ] map sift dup empty? [ 2drop f ] [
+        dup [ allocation ] map sift drop f ] [
             dup [ t eq? not ] all? [
                 dup [ length ] map all-equal? [
                     nip flip
@@ -23,7 +23,7 @@ M: #branch escape-analysis*
                     [ record-allocations ] keep
                 ] [ drop add-escaping-values t ] if
             ] [ drop add-escaping-values t ] if
-        ] if
+        ] if-empty
     ] map ;
 
 : merge-allocations ( in-values out-values -- )
index 08481726dcdf74f7e98c569e4c1414d34a316cd6..587dd6938b2eca6f7491b67093e63957568d0d98 100644 (file)
@@ -205,5 +205,5 @@ M: node normalize* ;
     dup [ collect-label-info ] each-node
     dup count-introductions make-values
     [ (normalize) ] [ nip ] 2bi
-    dup empty? [ drop ] [ #introduce prefix ] if
+    [ #introduce prefix ] unless-empty
     rename-node-values ;
index 8f2220aaaf8dabd3e25bc5938a2174b3fd0c3fcb..0891a6629cc9384fed22064a9d84cd832a2a8a47 100644 (file)
@@ -237,9 +237,8 @@ DEFER: (value-info-union)
     } cond ;
 
 : value-infos-union ( infos -- info )
-    dup empty?
-    [ drop null-info ]
-    [ dup first [ value-info-union ] reduce ] if ;
+    [ null-info ]
+    [ dup first [ value-info-union ] reduce ] if-empty ;
 
 : literals<= ( info1 info2 -- ? )
     {
index 2bb3fa0cfc89c201efb05623c48338750d2aa8e0..b6c798ca3ca840ecb105d6ea96ed4a3b4a31ada2 100755 (executable)
@@ -185,7 +185,7 @@ M: #return-recursive inputs/outputs [ in-d>> ] [ out-d>> ] bi ;
     [ label>> calls>> [ in-d>> ] map ] [ in-d>> ] bi suffix ;
 
 : ends-with-terminate? ( nodes -- ? )
-    dup empty? [ drop f ] [ peek #terminate? ] if ;
+    [ f ] [ peek #terminate? ] if-empty ;
 
 M: vector child-visitor V{ } clone ;
 M: vector #introduce, #introduce node, ;
index eba7f6933462c0732d8daa2f010a9fc21f621669..63284b28a30d985b908a4125cb37dd5e3c6498e4 100755 (executable)
@@ -87,11 +87,11 @@ M: postgresql-result-null summary ( obj -- str )
             { URL [ dup [ present ] when default-param-value ] }
             [ drop default-param-value ]
         } case 2array
-    ] 2map flip dup empty? [
-        drop f f
+    ] 2map flip [
+        f f
     ] [
         first2 [ >c-void*-array ] [ >c-uint-array ] bi*
-    ] if ;
+    ] if-empty ;
 
 : param-formats ( statement -- seq )
     in-params>> [ type>> type>param-format ] map >c-uint-array ;
index d3b99fcff3c03fd727b0f76e872ee1e287bc8167..c7fbcd859e8cec746c6cea36ba5908ebe8737174 100755 (executable)
@@ -136,7 +136,7 @@ ERROR: no-sql-type ;
 
 : modifiers ( spec -- string )
     modifiers>> [ lookup-modifier ] map " " join
-    dup empty? [ " " prepend ] unless ;
+    [ "" ] [ " " prepend ] if-empty ;
 
 HOOK: bind% db ( spec -- )
 HOOK: bind# db ( spec obj -- )
index 06c410c0e44a0c2db8a4a10dcea5b2d53cbb3362..4d01567131f47ac19bf81c01c73587285fa7254c 100755 (executable)
@@ -48,14 +48,12 @@ M: string error. print ;
     ] "" make print ;
 
 : restarts. ( -- )
-    restarts get dup empty? [
-        drop
-    ] [
+    restarts get [
         nl
         "The following restarts are available:" print
         nl
         [ restart. ] each-index
-    ] if ;
+    ] unless-empty ;
 
 : print-error ( error -- )
     [ error. flush ] curry
index baf2ccaba205114be54068b5aaa40c09fce60661..c029423714ad292f8e3da8fcb28dee58620a8834 100644 (file)
@@ -102,7 +102,12 @@ list = ((list-item nl)+ list-item? | list-item)
 code       =  '[' (!('{' | nl | '[').)+ '{' (!("}]").)+ "}]"
     => [[ [ second >string ] [ fourth >string ] bi code boa ]]
 
-stand-alone      = (code | heading | list | table | paragraph | nl)*
+simple-code
+           = "[{" (!("}]").)+ "}]"
+    => [[ second f swap code boa ]]
+
+stand-alone
+           = (code | simple-code | heading | list | table | paragraph | nl)*
 ;EBNF
 
 
@@ -137,7 +142,7 @@ stand-alone      = (code | heading | list | table | paragraph | nl)*
     ] [
         escape-link
         >r "<img src=\"" write write "\"" write r>
-        dup empty? [ drop ] [ " alt=\"" write write "\"" write ] if
+        [ " alt=\"" write write "\"" write ] unless-empty
         "/>" write
     ] if ;
 
index e2feb3cc171cb2399ab04b104559687635cee4ee..2b84d58d068ef88b04b8c67c728ff61105a4c932 100755 (executable)
@@ -14,13 +14,13 @@ DEFER: shallow-fry
 
 : ((shallow-fry)) ( accum quot adder -- result )
     >r shallow-fry r>
-    append swap dup empty? [ drop ] [
+    append swap [
         [ prepose ] curry append
-    ] if ; inline
+    ] unless-empty ; inline
 
 : (shallow-fry) ( accum quot -- result )
-    dup empty? [
-        drop 1quotation
+    [
+        1quotation
     ] [
         unclip {
             { \ , [ [ curry ] ((shallow-fry)) ] }
@@ -31,7 +31,7 @@ DEFER: shallow-fry
 
             [ swap >r suffix r> (shallow-fry) ]
         } case
-    ] if ;
+    ] if-empty ;
 
 : shallow-fry ( quot -- quot' ) [ ] swap (shallow-fry) ;
 
index d42972c360e7c63cc5eec8e1d6a43fa6546238e1..1370ae95b2f02653e6d201e0ce138f328bbca688 100755 (executable)
@@ -23,11 +23,11 @@ SYMBOL: rest
 \r
 : render-validation-messages ( -- )\r
     form get errors>>\r
-    dup empty? [ drop ] [\r
+    [\r
         <ul "errors" =class ul>\r
             [ <li> escape-string write </li> ] each\r
         </ul>\r
-    ] if ;\r
+    ] unless-empty ;\r
 \r
 CHLOE: validation-messages drop render-validation-messages ;\r
 \r
@@ -47,11 +47,11 @@ TUPLE: action rest authorize init display validate submit ;
     2tri ;\r
 \r
 : set-nested-form ( form name -- )\r
-    dup empty? [\r
-        drop merge-forms\r
+    [\r
+        merge-forms\r
     ] [\r
         unclip [ set-nested-form ] nest-form\r
-    ] if ;\r
+    ] if-empty ;\r
 \r
 : restore-validation-errors ( -- )\r
     form cget [\r
index fb4fbb898fd061348084255fa6c0fdb28c180fce..e6d85809b9867511dcd10dd6cee96cbffbf82a28 100644 (file)
@@ -42,8 +42,8 @@ IN: furnace.auth.features.edit-profile
         [
             logged-in-user get
 
-            "new-password" value dup empty?
-            [ drop ] [ >>encoded-password ] if
+            "new-password" value
+            [ >>encoded-password ] unless-empty
 
             "realname" value >>realname
             "email" value >>email
index fadd3988821beadeaa0fe29a6a9a36f09a264785..9dfaa4902860b6d054074022de9a8f0936f0bd28 100644 (file)
@@ -112,8 +112,7 @@ SYMBOL: exit-continuation
 
 ! Chloe tags
 : parse-query-attr ( string -- assoc )
-    dup empty?
-    [ drop f ] [ "," split [ dup value ] H{ } map>assoc ] if ;
+    [ f ] [ "," split [ dup value ] H{ } map>assoc ] if-empty ;
 
 : a-url-path ( tag -- string )
     [ "href" required-attr ]
index 7535ba8c1a55b19cfae1fa8975147c5c1b784cce..b2fff2237222ed283b1602a113e2b9f426467f5d 100755 (executable)
@@ -72,15 +72,13 @@ M: word article-parent "help-parent" word-prop ;
 M: word set-article-parent swap "help-parent" set-word-prop ;
 
 : $doc-path ( article -- )
-    help-path dup empty? [
-        drop
-    ] [
+    help-path [
         [
             help-path-style get [
                 "Parent topics: " write $links
             ] with-style
         ] ($block)
-    ] if ;
+    ] unless-empty ;
 
 : $title ( topic -- )
     title-style get [
@@ -112,8 +110,7 @@ M: word set-article-parent swap "help-parent" set-word-prop ;
     sort-articles [ \ $subsection swap 2array ] map print-element ;
 
 : $index ( element -- )
-    first call dup empty?
-    [ drop ] [ ($index) ] if ;
+    first call [ ($index) ] unless-empty ;
 
 : $about ( element -- )
     first vocab-help [ 1array $subsection ] when* ;
index b12dcaa8071b7d906ed986aa3dbbb8bd5810957a..4ad9067457f7eb10b6531ad56a3689a416329ab4 100755 (executable)
@@ -136,15 +136,14 @@ M: help-error error.
     ] with-scope ;
 
 : typos. ( assoc -- )
-    dup empty? [
-        drop
+    [
         "==== ALL CHECKS PASSED" print
     ] [
         [
             swap vocab-heading.
             [ error. nl ] each
         ] assoc-each
-    ] if ;
+    ] if-empty ;
 
 : help-lint ( prefix -- ) run-help-lint typos. ;
 
index d94b9c4b41c7dbfeae4d1f5d30b7048a09c25741..3077a93ed4b6983b0213df7e5ab98ee46601bfbd 100755 (executable)
@@ -15,7 +15,7 @@ IN: help.markup
 ! Element types are words whose name begins with $.
 
 PREDICATE: simple-element < array
-    dup empty? [ drop t ] [ first word? not ] if ;
+    [ t ] [ first word? not ] if-empty ;
 
 SYMBOL: last-element
 SYMBOL: span
@@ -201,8 +201,8 @@ ALIAS: $slot $snippet
     dup [ "related" set-word-prop ] curry each ;
 
 : $related ( element -- )
-    first dup "related" word-prop remove dup empty?
-    [ drop ] [ $see-also ] if ;
+    first dup "related" word-prop remove
+    [ $see-also ] unless-empty ;
 
 : ($grid) ( style quot -- )
     [
index 28bce0ec421108972053e3fc78da25e2fd24f9ef..da6ab9695988bf824b5951f829255a82d2d634d4 100644 (file)
@@ -13,10 +13,10 @@ IN: hints
     dup length <reversed>
     [ (picker) 2array ] 2map
     [ drop object eq? not ] assoc-filter
-    dup empty? [ drop [ t ] ] [
+    [ [ t ] ] [
         [ (make-specializer) ] { } assoc>map
         unclip [ swap [ f ] \ if 3array append [ ] like ] reduce
-    ] if ;
+    ] if-empty ;
 
 : specializer-cases ( quot word -- default alist )
     dup [ array? ] all? [ 1array ] unless [
index d21c743dcd4b74ec50c68841f8124de7412a832c..6a15b76bd3ab1b32718b5c5dd9535b06e2732f44 100755 (executable)
@@ -88,11 +88,11 @@ TUPLE: html-sub-stream < html-stream style parent ;
     ] make-css ;
 
 : span-tag ( style quot -- )
-    over span-css-style dup empty? [
-        drop call
+    over span-css-style [
+        call
     ] [
         <span =style span> call </span>
-    ] if ; inline
+    ] if-empty ; inline
 
 : format-html-span ( string style stream -- )
     stream>> [
@@ -121,11 +121,11 @@ M: html-span-stream dispose
     ] make-css ;
 
 : div-tag ( style quot -- )
-    swap div-css-style dup empty? [
-        drop call
+    swap div-css-style [
+        call
     ] [
         <div =style div> call </div>
-    ] if ; inline
+    ] if-empty ; inline
 
 : format-html-div ( string style stream -- )
     stream>> [
index c8fb7d365ae564e5eb55fcf1ad38db9c53b02e6e..7b451d5266e29b485ba8b5f8bc9f719e2199a045 100755 (executable)
@@ -50,14 +50,14 @@ SYMBOL: +editable+
 
 : describe* ( obj mirror keys -- )
     rot summary.
-    dup empty? [
-        2drop
+    [
+        drop
     ] [
         dup enum? [ +sequence+ on ] when
         standard-table-style [
             swap [ -rot describe-row ] curry each-index
         ] tabular-output
-    ] if ;
+    ] if-empty ;
 
 : describe ( obj -- )
     dup make-mirror dup sorted-keys describe* ;
index 79a1abd49cf51316419100a97c4ddbf3bafa28d5..8c9f26b1dd218250ca2089e2faeebac18fa9ca99 100755 (executable)
@@ -95,11 +95,11 @@ M: invalid-inet6 summary drop "Invalid IPv6 address" ;
 <PRIVATE
 
 : parse-inet6 ( string -- seq )
-    dup empty? [ drop f ] [
+    [ f ] [
         ":" split [
             hex> [ "Component not a number" throw ] unless*
         ] B{ } map-as
-    ] if ;
+    ] if-empty ;
 
 : pad-inet6 ( string1 string2 -- seq )
     2dup [ length ] bi@ + 8 swap -
index 754e69a476fcd5f6ed14eb5ecf2d3a08b8753cbf..b92eeb12502ac8f6c0962581418ad0e750145488 100644 (file)
@@ -3,14 +3,14 @@
 USING: lcs html.elements kernel qualified ;
 FROM: accessors => item>> ;
 FROM: io => write ;
-FROM: sequences => each empty? ;
+FROM: sequences => each if-empty ;
 FROM: xml.entities => escape-string ;
 IN: lcs.diff2html
 
 GENERIC: diff-line ( obj -- )
 
 : write-item ( item -- )
-    item>> dup empty? [ drop "&nbsp;" ] [ escape-string ] if write ;
+    item>> [ "&nbsp;" ] [ escape-string ] if-empty write ;
 
 M: retain diff-line
     <tr>
index 3ba52ea3915f1d2bb8293dec15ee4854dac6b4e1..5f237dd86b9954ae2df999418bb4d9be042eebc2 100755 (executable)
@@ -98,8 +98,8 @@ C: <quote> quote
 UNION: special local quote local-word local-reader local-writer ;
 
 : load-locals-quot ( args -- quot )
-    dup empty? [
-        drop [ ]
+    [
+        [ ]
     ] [
         dup [ local-reader? ] contains? [
             <reversed> [
@@ -108,14 +108,10 @@ UNION: special local quote local-word local-reader local-writer ;
         ] [
             length [ load-locals ] curry >quotation
         ] if
-    ] if ;
+    ] if-empty ;
 
 : drop-locals-quot ( args -- quot )
-    dup empty? [
-        drop [ ]
-    ] [
-        length [ drop-locals ] curry
-    ] if ;
+    [ [ ] ] [ length [ drop-locals ] curry ] if-empty ;
 
 : point-free-body ( quot args -- newquot )
     >r but-last-slice r> [ localize ] curry map concat ;
index 7810a4afadc2aec7f1d9e0b5bf2421475f1c7885..79d9410994909a60e72893173317ef01101c2c95 100755 (executable)
@@ -18,14 +18,14 @@ SYMBOL: insomniac-recipients
     ] "" make ;\r
 \r
 : (email-log-report) ( service word-names -- )\r
-    dupd ?analyze-log dup empty? [ 2drop ] [\r
+    dupd ?analyze-log drop ] [\r
         <email>\r
             swap >>body\r
             insomniac-recipients get >>to\r
             insomniac-sender get >>from\r
             swap email-subject >>subject\r
         send-email\r
-    ] if ;\r
+    ] if-empty ;\r
 \r
 \ (email-log-report) NOTICE add-error-logging\r
 \r
index fc90ada35a670e7e352b0b1047b9f8290dea91e6..caf6f39d5c95ba274abf6717edd5b3e1a6a07c22 100755 (executable)
@@ -17,9 +17,8 @@ TUPLE: history < model back forward ;
     swap value>> dup [ swap push ] [ 2drop ] if ;\r
 \r
 : go-back/forward ( history to from -- )\r
-    dup empty?\r
-    [ 3drop ]\r
-    [ >r dupd (add-history) r> pop swap set-model ] if ;\r
+    [ 2drop ]\r
+    [ >r dupd (add-history) r> pop swap set-model ] if-empty ;\r
 \r
 : go-back ( history -- )\r
     dup [ forward>> ] [ back>> ] bi go-back/forward ;\r
index 561af504c6c6e191d3ada3b6416e0b40af7b55c0..856b9ad4562c39f687214f1167878ec205862e3c 100755 (executable)
@@ -37,9 +37,8 @@ PRIVATE>
 
 : parse-multiline-string ( end-text -- str )
     [
-        lexer get column>> swap (parse-multiline-string)
-        lexer get (>>column)
-    ] "" make rest but-last ;
+        lexer get [ swap (parse-multiline-string) ] change-column drop
+    ] "" make rest-slice but-last ;
 
 : <"
     "\">" parse-multiline-string parsed ; parsing
index c52ab180276b1b81cd18bb7cd2db61c486e2f07b..3b9d034378350e0f7b5a310df64848294c1342dc 100755 (executable)
@@ -38,13 +38,13 @@ IN: prettyprint
     [ write-in nl ] when* ;
 
 : use. ( seq -- )
-    dup empty? [ drop ] [
+    [
         natural-sort [
             \ USING: pprint-word
             [ pprint-vocab ] each
             \ ; pprint-word
         ] with-pprint nl
-    ] if ;
+    ] unless-empty ;
 
 : vocabs. ( in use -- )
     dupd remove [ { "syntax" "scratchpad" } member? not ] filter
@@ -98,7 +98,7 @@ SYMBOL: ->
 "word-style" set-word-prop
 
 : remove-step-into ( word -- )
-    building get dup empty? [ drop ] [ nip pop wrapped>> ] if , ;
+    building get [ nip pop wrapped>> ] unless-empty , ;
 
 : (remove-breakpoints) ( quot -- newquot )
     [
index d37e2fc2b727c0fa219be4ae3e39e0ac9493fee5..133bf93b618452f00c1c3c173452ea32c04e33b6 100755 (executable)
@@ -34,14 +34,12 @@ M: f random-32* ( obj -- * ) no-random-number-generator ;
     ] keep head ;
 
 : random ( seq -- elt )
-    dup empty? [
-        drop f
-    ] [
+    [ f ] [
         [
             length dup log2 7 + 8 /i
             random-bytes byte-array>bignum swap mod
         ] keep nth
-    ] if ;
+    ] if-empty ;
 
 : delete-random ( seq -- elt )
     [ length random ] keep [ nth ] 2keep delete-nth ;
index 4d0fd6d8aa9ec05c370b943f142b58d0cd0ec951..8a268b79ebbabb9e2cca6258e4ed42b954ca3931 100755 (executable)
@@ -11,9 +11,9 @@ IN: stack-checker.backend
 : push-d ( obj -- ) meta-d get push ;
 
 : pop-d  ( -- obj )
-    meta-d get dup empty? [
-        drop <value> dup 1array #introduce, d-in inc
-    ] [ pop ] if ;
+    meta-d get [
+        <value> dup 1array #introduce, d-in inc
+    ] [ pop ] if-empty ;
 
 : peek-d ( -- obj ) pop-d dup push-d ;
 
@@ -40,7 +40,9 @@ IN: stack-checker.backend
 : output-r ( seq -- ) meta-r get push-all ;
 
 : pop-literal ( -- rstate obj )
-    pop-d [ 1array #drop, ] [ literal [ recursion>> ] [ value>> ] bi ] bi ;
+    pop-d
+    [ 1array #drop, ]
+    [ literal [ recursion>> ] [ value>> ] bi ] bi ;
 
 GENERIC: apply-object ( obj -- )
 
index 015e00ef4629a521bf3ea327f492823f12bacf28..46854831031df8b2c4e13f5c9377d03422d37265 100644 (file)
@@ -31,10 +31,10 @@ SYMBOL: +bottom+
 
 : unify-values ( values -- phi-out )
     remove-bottom
-    dup empty? [ drop <value> ] [
+    [ <value> ] [
         [ known ] map dup all-eq?
         [ first make-known ] [ drop <value> ] if
-    ] if ;
+    ] if-empty ;
 
 : phi-outputs ( phi-in -- stack )
     flip [ unify-values ] map ;
@@ -42,12 +42,12 @@ SYMBOL: +bottom+
 SYMBOL: quotations
 
 : unify-branches ( ins stacks -- in phi-in phi-out )
-    zip dup empty? [ drop 0 { } { } ] [
+    zip [ 0 { } { } ] [
         [ keys supremum ] [ ] [ balanced? ] tri
         [ dupd phi-inputs dup phi-outputs ]
         [ quotations get unbalanced-branches-error ]
         if
-    ] if ;
+    ] if-empty ;
 
 : branch-variable ( seq symbol -- seq )
     '[ , _ at ] map ;
index ade47d8e9171db8942634f83a1b380e0f5c29116..2d962d5fad5ca551aa31ca557857a8861fe315cb 100644 (file)
@@ -26,8 +26,8 @@ M: inference-error error-help error>> error-help ;
 
 M: inference-error error.
     [
-        rstate>> dup empty?
-        [ drop ] [ "Nesting:" print stack. ] if
+        rstate>>
+        [ "Nesting:" print stack. ] unless-empty
     ] [ error>> error. ] bi ;
 
 TUPLE: literal-expected ;
index 2773b8b4e43853a35fc32522fc4fb40c8832e2df..d60565e849d288caf8870ed0fddc1a0b176c08e9 100755 (executable)
@@ -69,15 +69,15 @@ IN: stack-checker.transforms
 \ cond [ cond>quot ] 1 define-transform
 
 \ case [
-    dup empty? [
-        drop [ no-case ]
+    [
+        [ no-case ]
     ] [
         dup peek quotation? [
             dup peek swap but-last
         ] [
             [ no-case ] swap
         ] if case>quot
-    ] if
+    ] if-empty
 ] 1 define-transform
 
 \ cleave [ cleave>quot ] 1 define-transform
index 065db4d8c1250f900353e8417e19c0c4d29f6c0a..0ebda89b1522cf2524220a2a98ff309c2374092d 100755 (executable)
@@ -73,7 +73,7 @@ SYMBOL: deploy-image
 : deploy-config ( vocab -- assoc )
     dup default-config swap
     dup deploy-config-path vocab-file-contents
-    parse-fresh dup empty? [ drop ] [ first assoc-union ] if ;
+    parse-fresh [ first assoc-union ] unless-empty ;
 
 : set-deploy-config ( assoc vocab -- )
     >r unparse-use string-lines r>
index b2b13a82a8015bcc1c3fae21673b050626eb66e8..d3304bbdb1c1757318945c1ca3297cabc6defff1 100755 (executable)
@@ -67,8 +67,7 @@ SYMBOL: this-test
 : test-failures. ( assoc -- )
     [
         nl
-        dup empty? [
-            drop
+        [
             "==== ALL TESTS PASSED" print
         ] [
             "==== FAILING TESTS:" print
@@ -76,16 +75,16 @@ SYMBOL: this-test
                 swap vocab-heading.
                 [ failure. nl ] each
             ] assoc-each
-        ] if
+        ] if-empty
     ] [
         "==== NOTHING TO TEST" print
     ] if* ;
 
 : run-tests ( prefix -- failures )
-    child-vocabs dup empty? [ drop f ] [
+    child-vocabs [ f ] [
         [ dup run-test ] { } map>assoc
         [ second empty? not ] filter
-    ] if ;
+    ] if-empty ;
 
 : test ( prefix -- )
     run-tests test-failures. ;
index a771a3573523fd01df79409d37e16f6d07ff4115..c3296df280e4f7584d6336f2cd47508c3911cb0e 100755 (executable)
@@ -36,14 +36,14 @@ IN: tools.vocabs.browser
 
 : vocabs. ( assoc -- )
     [
-        dup empty? [
-            2drop
+        [
+            drop
         ] [
             swap root-heading.
             standard-table-style [
                 vocab-headings. [ vocab. ] each
             ] ($grid)
-        ] if
+        ] if-empty
     ] assoc-each ;
 
 : describe-summary ( vocab -- )
@@ -98,10 +98,10 @@ C: <vocab-author> vocab-author
     ] when* ;
 
 : describe-words ( vocab -- )
-    words dup empty? [
+    words [
         "Words" $heading
-        dup natural-sort $links
-    ] unless drop ;
+        natural-sort $links
+    ] unless-empty ;
 
 : vocab-xref ( vocab quot -- vocabs )
     >r dup vocab-name swap words [ generic? not ] filter r> map
@@ -113,16 +113,16 @@ C: <vocab-author> vocab-author
 : vocab-usage ( vocab -- vocabs ) [ usage ] vocab-xref ;
 
 : describe-uses ( vocab -- )
-    vocab-uses dup empty? [
+    vocab-uses [
         "Uses" $heading
-        dup $vocab-links
-    ] unless drop ;
+        $vocab-links
+    ] unless-empty ;
 
 : describe-usage ( vocab -- )
-    vocab-usage dup empty? [
+    vocab-usage [
         "Used by" $heading
-        dup $vocab-links
-    ] unless drop ;
+        $vocab-links
+    ] unless-empty ;
 
 : $describe-vocab ( element -- )
     first
index cc49d283b4564f6dacc4405025a817f5f9986450..1c7e8d28d2c8222546c18dfbac7cc6faa7e2d927 100755 (executable)
@@ -165,11 +165,11 @@ MEMO: vocab-file-contents ( vocab name -- seq )
 \r
 : vocab-summary ( vocab -- summary )\r
     dup dup vocab-summary-path vocab-file-contents\r
-    dup empty? [\r
-        drop vocab-name " vocabulary" append\r
+    [\r
+        vocab-name " vocabulary" append\r
     ] [\r
         nip first\r
-    ] if ;\r
+    ] if-empty ;\r
 \r
 M: vocab summary\r
     [\r
@@ -212,11 +212,9 @@ M: vocab-link summary vocab-summary ;
 \r
 : (all-child-vocabs) ( root name -- vocabs )\r
     [ vocab-dir append-path subdirs ] keep\r
-    dup empty? [\r
-        drop\r
-    ] [\r
+    [\r
         swap [ "." swap 3append ] with map\r
-    ] if ;\r
+    ] unless-empty ;\r
 \r
 : vocabs-in-dir ( root name -- )\r
     dupd (all-child-vocabs) [\r
index 9c6b87b4390970c84e36909fd422f6c975c49b9d..c1073eda8c2a03ad6ddc25dcc8a9fe3535d45e3b 100755 (executable)
@@ -197,7 +197,7 @@ SYMBOL: +stopped+
 : step-back-msg ( continuation -- continuation' )
     walker-history tget
     [ pop* ]
-    [ dup empty? [ drop ] [ nip pop ] if ] bi ;
+    [ [ nip pop ] unless-empty ] bi ;
 
 : walker-suspended ( continuation -- continuation' )
     +suspended+ set-status
index 6b53d25ea1b2bb1ebc3ae51c0f999746c6e5bcaf..1170ea3fd15bcf87d83e5b400f34a615c94f98ef 100755 (executable)
@@ -108,7 +108,7 @@ SYMBOL: double-click-timeout
 
 : drag-gesture ( -- )
     hand-buttons get-global
-    dup empty? [ drop ] [ first <drag> button-gesture ] if ;
+    [ first <drag> button-gesture ] unless-empty ;
 
 SYMBOL: drag-timer
 
@@ -170,7 +170,7 @@ SYMBOL: drag-timer
 
 : modifier ( mod modifiers -- seq )
     [ second swap bitand 0 > ] with filter
-    0 <column> prune dup empty? [ drop f ] [ >array ] if ;
+    0 <column> prune [ f ] [ >array ] if-empty ;
 
 : drag-loc ( -- loc )
     hand-loc get-global hand-click-loc get-global v- ;
index 683eff9457ff6d5ef723b3f30f69808923026261..4c20abca8773f7765610921c94da403a1bc91896 100755 (executable)
@@ -72,11 +72,9 @@ M: listener-operation invoke-command ( target command -- )
     evaluate-input ;
 
 : listener-run-files ( seq -- )
-    dup empty? [
-        drop
-    ] [
+    [
         [ [ run-file ] each ] curry call-listener
-    ] if ;
+    ] unless-empty ;
 
 : com-end ( listener -- )
     input>> interactor-eof ;
index fe19685b53e0b9ad63478af10cd29e5c10fa5589..e4018e4d20a2c48d855d4e6bccfed632d729d89c 100755 (executable)
@@ -80,10 +80,10 @@ VALUE: grapheme-table
     nip swap length or 1+ ;
 
 : (>graphemes) ( str -- )
-    dup empty? [ drop ] [
+    [
         dup first-grapheme cut-slice
         swap , (>graphemes)
-    ] if ;
+    ] unless-empty ;
 
 : >graphemes ( str -- graphemes )
     [ (>graphemes) ] { } make ;
index 782ebae5160cab86b835a01278ab9126b00495c4..59b616ecc7152f6cbb19ac3ab00d7dd7d7afbbd5 100755 (executable)
@@ -100,7 +100,7 @@ unless
     "windows.com.wrapper.callbacks" create ;
 
 : (finish-thunk) ( param-count thunk quot -- thunked-quot )
-    [ dup empty? [ 2drop [ ] ] [ swap 1- '[ , , ndip ] ] if ]
+    [ [ drop [ ] ] [ swap 1- '[ , , ndip ] ] if-empty ]
     dip compose ;
 
 : (make-interface-callbacks) ( interface-name quots iunknown-methods n -- words )
index 2e91c23f60d111c8c94a89bd0bf1b919c156d442..0c3ef2c1df718ab7161e12c0b9ac9f7d67fba289 100644 (file)
@@ -164,7 +164,7 @@ SYMBOL: ns-stack
         T{ name f "" "encoding" f }
         T{ name f "" "standalone" f }
     } diff
-    dup empty? [ drop ] [ <extra-attrs> throw ] if ; 
+    [ <extra-attrs> throw ] unless-empty ; 
 
 : good-version ( version -- version )
     dup { "1.0" "1.1" } member? [ <bad-version> throw ] unless ;
index 8bda10102da13baee5afc899facdf5a24c3ed815..0c98e9a48e49e639129a441baa11757cb326e08e 100644 (file)
@@ -34,7 +34,7 @@ SYMBOL: indenter
 : ?filter-children ( children -- no-whitespace )\r
     xml-pprint? get [\r
         [ dup string? [ trim-whitespace ] when ] map\r
-        [ dup empty? swap string? and not ] filter\r
+        [ [ empty? ] [ string? ] bi and not ] filter\r
     ] when ;\r
 \r
 : print-name ( name -- )\r
index 0f419678d1c0af11d00153988d274743001f1871..b32bac3a18b8bc04925411891a20466452ab1315 100755 (executable)
@@ -208,9 +208,9 @@ M: anonymous-complement (classes-intersect?)
 \r
 : min-class ( class seq -- class/f )\r
     over [ classes-intersect? ] curry filter\r
-    dup empty? [ 2drop f ] [\r
+    drop f ] [\r
         tuck [ class<= ] with all? [ peek ] [ drop f ] if\r
-    ] if ;\r
+    ] if-empty ;\r
 \r
 GENERIC: (flatten-class) ( class -- )\r
 \r
index b0e4754682b9f3029fe15034a723bb480d6ab477..ee687c2939abd1e49a7118eca546e4686582995b 100644 (file)
@@ -44,11 +44,11 @@ M: builtin-class (classes-intersect?)
 
 M: anonymous-intersection (flatten-class)
     participants>> [ flatten-builtin-class ] map
-    dup empty? [
-        drop builtins get sift [ (flatten-class) ] each
+    [
+        builtins get sift [ (flatten-class) ] each
     ] [
         unclip [ assoc-intersect ] reduce [ swap set ] assoc-each
-    ] if ;
+    ] if-empty ;
 
 M: anonymous-complement (flatten-class)
     drop builtins get sift [ (flatten-class) ] each ;
index bb7e0adc6222653486ed5407125ab17ddc415a2b..55831fcdb4936e89e85e8f0b9d8a631b73b5e147 100644 (file)
@@ -8,14 +8,14 @@ PREDICATE: intersection-class < class
     "metaclass" word-prop intersection-class eq? ;
 
 : intersection-predicate-quot ( members -- quot )
-    dup empty? [
-        drop [ drop t ]
+    [
+        [ drop t ]
     ] [
         unclip "predicate" word-prop swap [
             "predicate" word-prop [ dup ] swap [ not ] 3append
             [ drop f ]
         ] { } map>assoc alist>quot
-    ] if ;
+    ] if-empty ;
 
 : define-intersection-predicate ( class -- )
     dup participants intersection-predicate-quot define-predicate ;
index 0865de16c3e88336a4c9678876aa631f05fe8ec1..531658a5e0c5507799616f4d14a9ed332106493c 100644 (file)
@@ -26,7 +26,7 @@ ERROR: duplicate-slot-names names ;
 
 : check-duplicate-slots ( slots -- )
     slot-names duplicates
-    dup empty? [ drop ] [ duplicate-slot-names ] if ;
+    [ duplicate-slot-names ] unless-empty ;
 
 ERROR: invalid-slot-name name ;
 
index fbb1925363b7b4fa8b530fe38db607afe07f5165..81a0db52be467a332021d0ed0e711e47d8e1b148 100755 (executable)
@@ -8,14 +8,14 @@ PREDICATE: union-class < class
     "metaclass" word-prop union-class eq? ;
 
 : union-predicate-quot ( members -- quot )
-    dup empty? [
-        drop [ drop f ]
+    [
+        [ drop f ]
     ] [
         unclip "predicate" word-prop swap [
             "predicate" word-prop [ dup ] prepend
             [ drop t ]
         ] { } map>assoc alist>quot
-    ] if ;
+    ] if-empty ;
 
 : define-union-predicate ( class -- )
     dup members union-predicate-quot define-predicate ;
index bed1c16bcf0f72ec695c47e4ffdec4eda0746dc9..154e1c30ac098180e80702b5c921a4079b1a09a9 100755 (executable)
@@ -21,7 +21,7 @@ M: object dispose
 : dispose-each ( seq -- )
     [
         [ [ dispose ] curry [ , ] recover ] each
-    ] { } make dup empty? [ drop ] [ peek rethrow ] if ;
+    ] { } make [ peek rethrow ] unless-empty ;
 
 : with-disposal ( object quot -- )
     over [ dispose ] curry [ ] cleanup ; inline
index 93405fe7c04003f5f57bb72d197d88737c080e62..e52799d10ab5e3e65a523ede96570204dcbfaab9 100755 (executable)
@@ -59,7 +59,7 @@ HOOK: (file-appender) io-backend ( path -- stream )
 HOOK: root-directory? io-backend ( path -- ? )
 
 M: object root-directory? ( path -- ? )
-    dup empty? [ drop f ] [ [ path-separator? ] all? ] if ;
+    [ f ] [ [ path-separator? ] all? ] if-empty ;
 
 ERROR: no-parent-directory path ;
 
@@ -80,7 +80,7 @@ ERROR: no-parent-directory path ;
 
 : head-path-separator? ( path1 ? -- ?' )
     [
-        dup empty? [ drop t ] [ first path-separator? ] if
+        [ t ] [ first path-separator? ] if-empty
     ] [
         drop f
     ] if ;
index 607076b80989f43f98a30e40995c92ffd31b3498..b2b75509e9874a4a458e409e4886c0d1df3806b1 100755 (executable)
@@ -18,7 +18,7 @@ M: growable stream-flush drop ;
     <string-writer> swap [ output-stream get ] compose with-output-stream*
     >string ; inline
 
-M: growable stream-read1 dup empty? [ drop f ] [ pop ] if ;
+M: growable stream-read1 [ f ] [ pop ] if-empty ;
 
 : harden-as ( seq growble-exemplar -- newseq )
     underlying>> like ;
@@ -39,13 +39,13 @@ M: growable stream-read-until
     ] if ;
 
 M: growable stream-read
-    dup empty? [
-        2drop f
+    [
+        drop f
     ] [
         [ length swap - 0 max ] keep
         [ swap growable-read-until ] 2keep
         set-length
-    ] if ;
+    ] if-empty ;
 
 M: growable stream-read-partial
     stream-read ;
index 4ada1ece9a514e535213b8808ba6e8c2dcced76c..f9b4abaada7f53e1621b7a35fa13ea9e91adc72c 100755 (executable)
@@ -335,6 +335,42 @@ HELP: if-empty
     "6"
 } ;
 
+HELP: when-empty
+{ $values
+     { "seq" sequence } { "quot1" "the first quotation of an " { $link if-empty } } }
+{ $description "Makes an implicit check if the sequence is empty. An empty sequence is dropped and the " { $snippet "quot1" } " is called." }
+{ $examples "This word is equivalent to " { $link if-empty } " with an empty second quotation:"
+    { $example
+    "USING: sequences prettyprint ;"
+    "{ } [ { 4 5 6 } ] [ ] if-empty ."
+    "{ 4 5 6 }"
+    }
+    { $example
+    "USING: sequences prettyprint ;"
+    "{ } [ { 4 5 6 } ] when-empty ."
+    "{ 4 5 6 }"
+    }
+} ;
+
+HELP: unless-empty
+{ $values
+     { "seq" sequence } { "quot2" "the second quotation of an " { $link if-empty } } }
+{ $description "Makes an implicit check if the sequence is empty. An empty sequence is dropped. Otherwise, the " { $snippet "quot2" } " is called on the sequence.." }
+{ $examples "This word is equivalent to " { $link if-empty } " with an empty first quotation:"
+    { $example
+    "USING: sequences prettyprint ;"
+    "{ 4 5 6 } [ ] [ sum ] if-empty ."
+    "15"
+    }
+    { $example
+    "USING: sequences prettyprint ;"
+    "{ 4 5 6 } [ sum ] unless-empty ."
+    "15"
+    }
+} ;
+
+{ if-empty when-empty unless-empty } related-words
+
 HELP: delete-all
 { $values { "seq" "a resizable sequence" } }
 { $description "Resizes the sequence to zero length, removing all elements. Not all sequences are resizable." }
index b7f36eb07139680afe64afac76862dc54355745a..18291aaa7046c134bfd816c45a776039e91e1a89 100755 (executable)
@@ -34,7 +34,7 @@ M: sequence shorten 2dup length < [ set-length ] [ 2drop ] if ;
 
 : when-empty ( seq quot1 -- ) [ ] if-empty ; inline
 
-: unless-empty ( seq quot1 -- ) [ ] swap if-empty ; inline
+: unless-empty ( seq quot2 -- ) [ ] swap if-empty ; inline
 
 : delete-all ( seq -- ) 0 swap set-length ;
 
@@ -91,7 +91,7 @@ M: sequence set-nth-unsafe set-nth ;
 ! The f object supports the sequence protocol trivially
 M: f length drop 0 ;
 M: f nth-unsafe nip ;
-M: f like drop dup empty? [ drop f ] when ;
+M: f like drop [ f ] when-empty ;
 
 INSTANCE: f immutable-sequence
 
@@ -630,14 +630,14 @@ M: slice equal? over slice? [ sequence= ] [ 2drop f ] if ;
     0 [ length + ] reduce ;
 
 : concat ( seq -- newseq )
-    dup empty? [
-        drop { }
+    [
+        { }
     ] [
         [ sum-lengths ] keep
         [ first new-resizable ] keep
         [ [ over push-all ] each ] keep
         first like
-    ] if ;
+    ] if-empty ;
 
 : joined-length ( seq glue -- n )
     >r dup sum-lengths swap length 1 [-] r> length * + ;
index db2c50173c9f8c85c7585fb448d4e9e5bf4bb9f9..df397025f60f9399971fb1efcc1a60a8b5afce9e 100755 (executable)
@@ -50,9 +50,8 @@ PRIVATE>
     [ amb-integer ] [ nth ] bi ;\r
 \r
 : amb ( seq -- elt )\r
-    dup empty?\r
-    [ drop fail f ]\r
-    [ unsafe-amb ] if ; inline\r
+    [ fail f ]\r
+    [ unsafe-amb ] if-empty ; inline\r
 \r
 MACRO: amb-execute ( seq -- quot )\r
     [ length 1 - ] [ <enum> [ 1quotation ] assoc-map ] bi\r
index 52cb9914b4e8db65334d30a640537f839bab2ee3..915744491fa6ce3b1c97a495da767e755592a592 100644 (file)
@@ -27,7 +27,7 @@ M: multi-cord virtual@
     [ first - ] [ second ] bi ;
 
 M: multi-cord virtual-seq
-    seqs>> dup empty? [ drop f ] [ first second ] if ;
+    seqs>> [ f ] [ first second ] if-empty ;
 
 : <cord> ( seqs -- cord )
     dup length 2 = [
index 4a7d251425e57706fa5fbb37a7292a52ce9f8b3c..5267dd6d6e9f3c69912a2a69c86db526a5ea2ba7 100755 (executable)
@@ -58,7 +58,7 @@ SINGLETON: iokit-game-input-backend
     buttons-matching-hash device-elements-matching length ;
 
 : ?axis ( device hash -- axis/f )
-    device-elements-matching dup empty? [ drop f ] [ first ] if ;
+    device-elements-matching [ f ] [ first ] if-empty ;
 
 : ?x-axis ( device -- ? )
     x-axis-matching-hash ?axis ;
index 94a50196a6b6041264d20766df8426a6937a5cbd..ccd225e6e0b9341eaf8aeb911bb2f2eba03e2992 100644 (file)
@@ -103,11 +103,9 @@ SYMBOL: tagstack
     [ get-char CHAR: < = ] take-until ;
 
 : parse-text ( -- )
-    read-until-< dup empty? [
-        drop
-    ] [
+    read-until-< [
         make-text-tag push-tag
-    ] if ;
+    ] unless-empty ;
 
 : (parse-attributes) ( -- )
     read-whitespace*
index c7925b94bed4b86a57e5c8724294bbbd9eee72e1..b843c73983d6adafb616fef992dee8bc98ec9a7f 100755 (executable)
@@ -34,9 +34,8 @@ M: no-inverse summary
     drop "The word cannot be used in pattern matching" ;
 
 : next ( revquot -- revquot* first )
-    dup empty?
     [ "Badly formed math inverse" throw ]
-    [ unclip-slice ] if ;
+    [ unclip-slice ] if-empty ;
 
 : constant-word? ( word -- ? )
     stack-effect
@@ -116,8 +115,7 @@ M: pop-inverse inverse
     "pop-inverse" word-prop compose call ;
 
 : (undo) ( revquot -- )
-    dup empty? [ drop ]
-    [ unclip-slice inverse % (undo) ] if ;
+    [ unclip-slice inverse % (undo) ] unless-empty ;
 
 : [undo] ( quot -- undo )
     flatten fold reverse [ (undo) ] [ ] make ;
index 2835023c0d624aedda30d7f2baf9c114f990addd..163517698ae94fa2636032c236c33c14707ecaee 100755 (executable)
@@ -8,7 +8,7 @@ IN: irc.ui.commandparser
 "irc.ui.commands" require\r
 \r
 : command ( string string -- string command )\r
-    dup empty? [ drop "say" ] when\r
+    [ "say" ] when-empty\r
     dup "irc.ui.commands" lookup\r
     [ nip ]\r
     [ " " append prepend "quote" "irc.ui.commands" lookup ] if* ;\r
index 1aebfcbfcb684b0fe76d4d942703723070fefbe4..457a98482056a513f25dc0b4ae771d26507302bb 100755 (executable)
@@ -32,8 +32,8 @@ TUPLE: irc-tab < frame listener client window ;
 : dark-green T{ rgba f 0.0 0.5 0.0 1 } ;\r
 \r
 : dot-or-parens ( string -- string )\r
-    dup empty? [ drop "." ]\r
-    [ "(" prepend ")" append ] if ;\r
+    [ "." ]\r
+    [ "(" prepend ")" append ] if-empty ;\r
 \r
 GENERIC: write-irc ( irc-message -- )\r
 \r
index 2b67a3755e23d06901faea9a1165c0dcc69ed534..5bd679d92a737e29ae153b36669c120504db6ee5 100755 (executable)
@@ -115,8 +115,7 @@ DEFER: (d)
 : x.dy ( x y -- vec ) (d) wedge -1 alt*n ;
 
 : (d) ( product -- value )
-    dup empty?
-    [ drop H{ } ] [ unclip swap [ x.dy ] 2keep dx.y alt+ ] if ;
+    [ H{ } ] [ unclip swap [ x.dy ] 2keep dx.y alt+ ] if-empty ;
 
 : linear-op ( vec quot -- vec )
         [
@@ -211,7 +210,7 @@ DEFER: (d)
 : m'.m ( matrix -- matrix' ) dup flip swap m. ;
 
 : empty-matrix? ( matrix -- ? )
-    dup empty? [ drop t ] [ first empty? ] if ;
+    [ t ] [ first empty? ] if-empty ;
 
 : ?m+ ( m1 m2 -- m3 )
     over empty-matrix? [
index 1883f5692982a02ccc3096e1cc7828dbf3627ddf..018b041afd493be3c12987584a8ff54d477d2845 100644 (file)
@@ -15,7 +15,7 @@ IN: math.polynomials
 : 2pad-right ( p p n -- p p ) 0 [ pad-right swap ] 2keep pad-right swap ;
 : pextend ( p p -- p p ) 2dup [ length ] bi@ max 2pad-right ;
 : pextend-left ( p p -- p p ) 2dup [ length ] bi@ max 2pad-left ;
-: unempty ( seq -- seq ) dup empty? [ drop { 0 } ] when ;
+: unempty ( seq -- seq ) [ { 0 } ] when-empty ;
 : 2unempty ( seq seq -- seq seq ) [ unempty ] bi@ ;
 
 PRIVATE>
index aba7e90bc906da5b1cf6cd7ed7e93742dc649ca2..83d53c42153a59040665e4bb903881eeef9369c8 100644 (file)
@@ -10,11 +10,11 @@ IN: math.primes.factors
 
 : (count) ( n d -- n' )
     [ (factor) ] { } make
-    dup empty? [ drop ] [ [ first ] keep length 2array , ] if ;
+    [ [ first ] keep length 2array , ] unless-empty ;
 
 : (unique) ( n d -- n' )
     [ (factor) ] { } make
-    dup empty? [ drop ] [ first , ] if ;
+    [ first , ] unless-empty ;
 
 : (factors) ( quot list n -- )
     dup 1 > [ swap uncons swap >r pick call r> swap (factors) ] [ 3drop ] if ;
index b8256533bf438f946f6bfb128bb4eb7e263a7e74..387be4d7912f240cada6484e965b884efc76fd87 100755 (executable)
@@ -57,11 +57,9 @@ SYMBOL: and-needed?
 
 : text-with-scale ( index seq -- str )
     dupd nth 3digits>text swap
-    scale-numbers dup empty? [
-        drop
-    ] [
+    scale-numbers [
         " " swap 3append
-    ] if ;
+    ] unless-empty ;
 
 : append-with-conjunction ( str1 str2 -- newstr )
     over length zero? [
index bf9f4d3a67952ba0a4089c1b5f72697bf9035b9a..fb743e15af24568ffc4fe9ee1b43175d85e57430 100644 (file)
@@ -22,7 +22,7 @@ ERROR: not-a-decimal x ;
 : parse-decimal ( str -- ratio )
     "." split1
     >r dup "-" head? [ drop t "0" ] [ f swap ] if r>
-    [ dup empty? [ drop "0" ] when ] bi@
+    [ [ "0" ] when-empty ] bi@
     dup length
     >r [ dup string>number [ nip ] [ not-a-decimal ] if* ] bi@ r>
     10 swap ^ / + swap [ neg ] when ;
index 8859f07340b4d8cfef8792d1d04856020d56b94f..a8025828f1fb6d876d6809e701f09ee18ec9dbea 100755 (executable)
@@ -112,10 +112,10 @@ SYMBOL: total
     dup length <reversed>
     [ picker 2array ] 2map
     [ drop object eq? not ] assoc-filter
-    dup empty? [ drop [ t ] ] [
+    [ [ t ] ] [
         [ (multi-predicate) ] { } assoc>map
         unclip [ swap [ f ] \ if 3array append [ ] like ] reduce
-    ] if ;
+    ] if-empty ;
 
 : argument-count ( methods -- n )
     keys 0 [ length max ] reduce ;
index b487b385b918ccde3c2c8bd9eac009e9176b6130..a5d4b36c0b651cf17f926960a148e3c982749314 100755 (executable)
@@ -84,7 +84,7 @@ M: string b, ( n string -- ) heap-size b, ;
     "\0" read-until [ drop f ] unless ;
 
 : read-c-string* ( n -- str/f )
-    read [ zero? ] trim-right dup empty? [ drop f ] when ;
+    read [ zero? ] trim-right [ f ] when-empty ;
 
 : (read-128-ber) ( n -- n )
     read1
index 9a2a08bcbeb45b4f7fea169f678f8a596ff5e192..7ae273f20a7cc76120c632ed3f55f46cb8a49db5 100644 (file)
@@ -163,11 +163,11 @@ USING: kernel math parser sequences combinators splitting ;
     } cond ;
 
 : -ion ( str -- newstr )
-    dup empty? [
-        drop "ion"
+    [
+        "ion"
     ] [
         dup "st" last-is? [ "ion" append ] unless
-    ] if ;
+    ] if-empty ;
 
 : step4 ( str -- newstr )
     dup {
index f64c345694d5690280d3b1ba548873fd79b22df3..1e6a2fb0b477be3526e97cb8b91db01f0dbd6295 100644 (file)
@@ -36,7 +36,7 @@ IN: project-euler.079
 
 : find-source ( seq -- elt )
     unzip diff prune
-    dup empty? [ "Topological sort failed" throw ] [ first ] if ;
+    [ "Topological sort failed" throw ] [ first ] if-empty ;
 
 : remove-source ( seq elt -- seq )
     [ swap member? not ] curry filter ;
@@ -45,7 +45,7 @@ IN: project-euler.079
     dup length 1 > [
         dup find-source dup , remove-source (topological-sort)
     ] [
-        dup empty? [ drop ] [ first [ , ] each ] if
+        [ first [ , ] each ] unless-empty
     ] if ;
 
 PRIVATE>
index 4a361210463fe252b9d6bf25ed87b4096aa1baf3..78ede328013cd382dd1333ba2652d8c427c7107f 100755 (executable)
@@ -155,11 +155,11 @@ M: lambda-word word-noise-factor
 : vocab-noise-factor ( vocab -- factor )\r
     words flatten-generics\r
     [ word-noise-factor dup 20 < [ drop 0 ] when ] map\r
-    dup empty? [ drop 0 ] [\r
+    [ 0 ] [\r
         [ [ sum ] [ length 5 max ] bi /i ]\r
         [ supremum ]\r
         bi +\r
-    ] if ;\r
+    ] if-empty ;\r
 \r
 : noisy-vocabs ( -- alist )\r
     vocabs [ dup vocab-noise-factor ] { } map>assoc\r
index b2e805304ed07914b069934a9ae7762d3846eef6..9975da00db05628c123072f7cd562aade7f9b3ec 100755 (executable)
@@ -18,23 +18,3 @@ HELP: each-withn
 "passed to the quotation given to each-withn for each element in the sequence."\r
 } \r
 { $see-also map-withn } ;\r
-\r
-HELP: if-seq\r
-{ $values { "seq" sequence } { "quot1" quotation } { "quot2" quotation } }\r
-{ $description "Makes an implicit check if the sequence is empty.  If the sequence has any elements, " { $snippet "quot1" } " is called on it.  Otherwise, the empty sequence is dropped and " { $snippet "quot2" } " is called." }\r
-{ $example\r
-    "USING: kernel prettyprint sequences sequences.lib ;"\r
-    "{ 1 2 3 } [ sum ] [ \"empty sequence\" throw ] if-seq ."\r
-    "6"\r
-} ;\r
-\r
-HELP: if-empty\r
-{ $values { "seq" sequence } { "quot1" quotation } { "quot2" quotation } }\r
-{ $description "Makes an implicit check if the sequence is empty. An empty sequence is dropped and " { $snippet "quot1" } " is called. Otherwise, if the sequence has any elements, " { $snippet "quot2" } " is called on it." }\r
-{ $example\r
-    "USING: kernel prettyprint sequences sequences.lib ;"\r
-    "{ 1 2 3 } [ \"empty sequence\" ] [ sum ] if-empty ."\r
-    "6"\r
-} ;\r
-\r
-{ if-seq if-empty } related-words\r
index 76f3bb4f5b61d159a11740fe6fe0b8cb1fd5c5dd..12bdd45c46cd67f985fc0e7e20ba712d4f302754 100755 (executable)
@@ -63,6 +63,3 @@ IN: sequences.lib.tests
 [ 1 2 { 3 4 } [ + + drop ] 2 each-withn  ] must-infer
 { 13 } [ 1 2 { 3 4 } [ + + ] 2 each-withn + ] unit-test
 [ { 910 911 912 } ] [ 10 900 3 [ + + ] map-with2 ] unit-test
-
-[ "empty" ] [ { } [ "not empty" ] [ "empty" ] if-seq ] unit-test
-[ { 1 } "not empty" ] [ { 1 } [ "not empty" ] [ "empty" ] if-seq ] unit-test
index 2eb3c44b421755f7380b9fc21beec35525011f6b..225b3b7d9ed84dc6fed4eb25245dacff2c9fc6f3 100755 (executable)
@@ -189,12 +189,3 @@ PRIVATE>
 
 : ?nth* ( n seq -- elt/f ? )
     2dup bounds-check? [ nth-unsafe t ] [ 2drop f f ] if ; flushable
-
-: if-seq ( seq quot1 quot2 -- ) [ f like ] 2dip if* ; inline
-: if-empty ( seq quot1 quot2 -- ) swap if-seq ; inline
-
-: when-empty ( seq quot1 -- ) [ ] if-empty ; inline
-
-: unless-empty ( seq quot1 -- ) [ ] swap if-empty ; inline
-
index 7604108b82cd00d9b130fa95cb8b9db52e0cc0f9..02005fcd1f6c4143f2dc928a0c817204d48383ac 100755 (executable)
@@ -19,8 +19,8 @@ M: dimensions-not-equal summary drop "Dimensions do not match" ;
     [ remove-one ] curry bi@ ;
 
 : symbolic-reduce ( seq seq -- seq seq )
-    2dup intersect dup empty?
-    [ drop ] [ first 2remove-one symbolic-reduce ] if ;
+    2dup intersect
+    [ first 2remove-one symbolic-reduce ] unless-empty ;
 
 : <dimensioned> ( n top bot -- obj )
     symbolic-reduce
index 283efa84120ce04d97026ad70316c75c089f2e74..6b765461e579c2b33128e85823fe3e797993f292 100644 (file)
@@ -21,10 +21,10 @@ IN: xml.syntax
 DEFER: >>
 
 : attributes-parsed ( accum quot -- accum )
-    dup empty? [ drop f parsed ] [
+    [ f parsed ] [
         >r \ >r parsed r> parsed
         [ H{ } make-assoc r> swap ] [ parsed ] each
-    ] if ;
+    ] if-empty ;
 
 : <<
     parsed-name [