]> gitweb.factorcode.org Git - factor.git/commitdiff
sift and harvest words added
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 14 May 2008 04:36:55 +0000 (23:36 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 14 May 2008 04:36:55 +0000 (23:36 -0500)
32 files changed:
core/bootstrap/primitives.factor
core/bootstrap/stage2.factor
core/cpu/x86/64/64.factor
core/inference/backend/backend.factor
core/parser/parser.factor
core/prettyprint/sections/sections.factor
core/sequences/sequences.factor
core/slots/deprecated/deprecated.factor
core/vocabs/vocabs.factor
extra/bunny/bunny.factor
extra/bunny/model/model.factor
extra/ftp/client/client.factor
extra/hardware-info/linux/linux.factor
extra/help/handbook/handbook.factor
extra/help/help.factor
extra/html/parser/analyzer/analyzer.factor
extra/http/client/client-tests.factor
extra/http/client/client.factor
extra/http/http.factor
extra/http/server/server.factor
extra/koszul/koszul.factor
extra/logging/server/server.factor
extra/peg/search/search.factor
extra/sequences/lib/lib.factor
extra/tools/vocabs/browser/browser.factor
extra/ui/gadgets/tracks/tracks.factor
extra/ui/tools/tools-tests.factor
extra/unicode/breaks/breaks.factor
extra/unicode/data/data.factor
extra/unicode/script/script.factor
extra/windows/com/syntax/syntax.factor
extra/wrap/wrap.factor

index 4aebef3e0dd6d238c664baeec8ad6ce7ff16babe..6fc8ca768557d351f3609626fb61ad47903e697f 100755 (executable)
@@ -160,11 +160,6 @@ bootstrapping? on
 "tuple-layout" "classes.tuple.private" create register-builtin
 
 ! Catch-all class for providing a default method.
-! "object" "kernel" create
-! [ f builtins get [ ] filter f union-class define-class ]
-! [ [ drop t ] "predicate" set-word-prop ]
-! bi
-
 "object" "kernel" create
 [ f f { } intersection-class define-class ]
 [ [ drop t ] "predicate" set-word-prop ]
index 2e087ff5bd3569d8d745e0aee54b37577440fc16..f94cc0ed37dfeb2adfa4b838ec09338ee6ca9c66 100755 (executable)
@@ -23,7 +23,7 @@ SYMBOL: bootstrap-time
 
 : load-components ( -- )
     "include" "exclude"
-    [ get-global " " split [ empty? not ] filter ] bi@
+    [ get-global " " split harvest ] bi@
     diff
     [ "bootstrap." prepend require ] each ;
 
index 9c44a6a6569c376e7d3cc49867a053d6264c84c5..ebaa6056ffd822a054c77887bb4bf5bf4b9814fb 100755 (executable)
@@ -184,7 +184,7 @@ stack-params "__stack_value" c-type set-c-type-reg-class >>
 : split-struct ( pairs -- seq )
     [
         [ 8 mod zero? [ t , ] when , ] assoc-each
-    ] { } make { t } split [ empty? not ] filter ;
+    ] { } make { t } split harvest ;
 
 : flatten-large-struct ( type -- )
     heap-size cell align
index 5896429ccfb6e17541837741a8a19901751b3ec0..c49e7fda8ab19642513e1825f2a5c010be5653ce 100755 (executable)
@@ -261,7 +261,7 @@ TUPLE: cannot-unify-specials ;
 
 : balanced? ( in out -- ? )
     [ dup [ length - ] [ 2drop f ] if ] 2map
-    [ ] filter all-equal? ;
+    sift all-equal? ;
 
 TUPLE: unbalanced-branches-error quots in out ;
 
@@ -281,7 +281,7 @@ TUPLE: unbalanced-branches-error quots in out ;
     2dup balanced? [
         over supremum -rot
         [ >r dupd r> unify-inputs ] 2map
-        [ ] filter unify-stacks
+        sift unify-stacks
         rot drop
     ] [
         unbalanced-branches-error
index 76c831cf13753b3cb090410e4cb04855d91fb7ca..f08ba8fbc2972bd552dc764fc31e4c35149c366b 100755 (executable)
@@ -207,7 +207,7 @@ SYMBOL: in
 : add-use ( seq -- ) [ use+ ] each ;
 
 : set-use ( seq -- )
-    [ vocab-words ] map [ ] filter >vector use set ;
+    [ vocab-words ] V{ } map-as sift use set ;
 
 : check-vocab-string ( name -- name )
     dup string?
@@ -278,7 +278,7 @@ M: no-word-error summary
     dup forward-reference? [
         drop
         use get
-        [ at ] with map [ ] filter
+        [ at ] with map sift
         [ forward-reference? not ] find nip
     ] [
         nip
index 11fa4da28ee990199377ef7de0760d3134822b15..73d362010717a0907dea62b9ac6338711096d882 100644 (file)
@@ -309,7 +309,7 @@ M: f section-end-group? drop f ;
             2dup 1+ swap ?nth next set
             swap nth dup split-before dup , split-after
         ] with each
-    ] { } make { t } split [ empty? not ] filter ;
+    ] { } make { t } split harvest ;
 
 : break-group? ( seq -- ? )
     [ first section-fits? ] [ peek section-fits? not ] bi and ;
index 8d0e3eec18d5512bbc0d3e9af2e4596482f63e99..cbddfa7d28dd2ce52208d17bf7a45d9cb3e13314 100755 (executable)
@@ -445,6 +445,12 @@ PRIVATE>
 : remove ( obj seq -- newseq )
     [ = not ] with filter ;
 
+: sift ( seq -- newseq )
+    [ ] filter ;
+
+: harvest ( seq -- newseq )
+    [ empty? not ] filter ;
+
 : cache-nth ( i seq quot -- elt )
     2over ?nth dup [
         >r 3drop r>
index 90f468a185c3bfe20cbb99af3a269e936a896304..3e2f899774dc07cc1b4254e06dfd35c10a63c4c4 100755 (executable)
@@ -86,7 +86,7 @@ PREDICATE: slot-writer < word "writing" word-prop >boolean ;
             { [ over string? ] [ >r dupd r> short-slot ] }\r
             { [ over array? ] [ long-slot ] }\r
         } cond\r
-    ] 2map [ ] filter nip ;\r
+    ] 2map sift nip ;\r
 \r
 : slot-of-reader ( reader specs -- spec/f )\r
     [ slot-spec-reader eq? ] with find nip ;\r
index edd82b2596332e99728c686bed05013201c2ae06..57951e864262b01415c3f355cad9a5f9c6d3bebf 100755 (executable)
@@ -76,7 +76,7 @@ SYMBOL: load-vocab-hook ! ( name -- )
 : words-named ( str -- seq )
     dictionary get values
     [ vocab-words at ] with map
-    [ ] filter ;
+    sift ;
 
 : child-vocab? ( prefix name -- ? )
     2dup = pick empty? or
index d546f9ea41c229a136732ca8fc8e7b70c6d86662..6ebd598dc6a722b2d354a16467e36604e539e83a 100755 (executable)
@@ -33,7 +33,7 @@ M: bunny-gadget graft* ( gadget -- )
     [ <bunny-fixed-pipeline> ]
     [ <bunny-cel-shaded> ]
     [ <bunny-outlined> ] tri 3array
-    [ ] filter >>draw-seq
+    sift >>draw-seq
     0 >>draw-n
     drop ;
 
index 239603755d795f344a1d43af7ac44697c208068e..95b5fe401d4265c5164489c93e87e3e77c09e015 100755 (executable)
@@ -6,7 +6,7 @@ float-arrays continuations namespaces sequences.lib accessors ;
 IN: bunny.model
 
 : numbers ( str -- seq )
-    " " split [ string>number ] map [ ] filter ;
+    " " split [ string>number ] map sift ;
 
 : (parse-model) ( vs is -- vs is )
     readln [
index 13cb21d7e402768d7055fa82176674b65b787689..88b83b7d66998cc5bb1bc5cfe1867319dc6e1636 100644 (file)
@@ -130,7 +130,7 @@ TUPLE: remote-file
 
 : parse-list ( ftp-response -- ftp-response )
     dup strings>>
-    [ " " split [ empty? not ] filter ] map
+    [ " " split harvest ] map
     dup length {
         { 9 [ parse-list-9 ] }
         { 8 [ parse-list-8 ] }
index 5d9ca6eaa7a9fbed0e6846bff571e54585bc3f70..89f42b43848fadd4f53a40e65554a74ab6287887 100644 (file)
@@ -7,7 +7,7 @@ IN: hardware-info.linux
 
 : uname ( -- seq )
     65536 "char" <c-array> [ (uname) io-error ] keep
-    "\0" split [ empty? not ] filter [ >string ] map
+    "\0" split harvest [ >string ] map
     6 "" pad-right ;
 
 : sysname ( -- string ) uname first ;
@@ -18,4 +18,4 @@ IN: hardware-info.linux
 : domainname ( -- string ) uname 5 swap nth ;
 
 : kernel-version ( -- seq )
-    release ".-" split [ ] filter 5 "" pad-right ;
+    release ".-" split harvest 5 "" pad-right ;
index a8271a0e3b7f13bb3c2eec65a4bd8927346481cc..dd4106239dd367f01e4d38cad7580863b6ac2d80 100755 (executable)
@@ -238,7 +238,7 @@ ARTICLE: "error-index" "Error index"
 { $index [ all-errors ] } ;
 
 ARTICLE: "type-index" "Type index"
-{ $index [ builtins get [ ] filter ] } ;
+{ $index [ builtins get sift ] } ;
 
 ARTICLE: "class-index" "Class index"
 { $index [ classes ] } ;
index 2d56251392b4348f256d1eda6b7e2bb4472e9c65..75a14e645bcd9940c80531b1096efad13f537e39 100755 (executable)
@@ -135,7 +135,7 @@ M: word set-article-parent swap "help-parent" set-word-prop ;
     ":vars - list all variables at error time" print ;
 
 : :help ( -- )
-    error get delegates [ error-help ] map [ ] filter
+    error get delegates [ error-help ] map sift
     {
         { [ dup empty? ] [ (:help-none) ] }
         { [ dup length 1 = ] [ first help ] }
index e9906f3f2a048b333dba6d1c67d577f9ee2b6e78..9a3ff8c7a7a18241cea393b17f1215cfa1de7ff2 100755 (executable)
@@ -77,12 +77,12 @@ IN: html.parser.analyzer
 : find-by-attribute-key ( key vector -- vector )
     >r >lower r>
     [ tag-attributes at ] with filter
-    [ ] filter ;
+    sift ;
 
 : find-by-attribute-key-value ( value key vector -- vector )
     >r >lower r>
     [ tag-attributes at over = ] with filter nip
-    [ ] filter ;
+    sift ;
 
 : find-first-attribute-key-value ( value key vector -- i/f tag/f )
     >r >lower r>
index 1d947b99e526f21f6ed56f3a0d624668984e96d4..9ad805b81b9b927886cd5eda14a7a2cd753edd8c 100755 (executable)
@@ -1,9 +1,7 @@
 USING: http.client http.client.private http tools.test
 tuple-syntax namespaces ;
-[ "localhost" 80 ] [ "localhost" parse-host ] unit-test
+[ "localhost" f ] [ "localhost" parse-host ] unit-test
 [ "localhost" 8888 ] [ "localhost:8888" parse-host ] unit-test
-[ "/foo" "localhost" 8888 ] [ "http://localhost:8888/foo" parse-url ] unit-test
-[ "/" "localhost" 8888 ] [ "http://localhost:8888" parse-url ] unit-test
 
 [ "foo.txt" ] [ "http://www.paulgraham.com/foo.txt" download-name ] unit-test
 [ "foo.txt" ] [ "http://www.arc.com/foo.txt?xxx" download-name ] unit-test
@@ -12,10 +10,11 @@ tuple-syntax namespaces ;
 
 [
     TUPLE{ request
+        protocol: http
         method: "GET"
         host: "www.apple.com"
-        path: "/index.html"
         port: 80
+        path: "/index.html"
         version: "1.1"
         cookies: V{ }
         header: H{ { "connection" "close" } }
@@ -26,3 +25,21 @@ tuple-syntax namespaces ;
         <get-request>
     ] with-scope
 ] unit-test
+
+[
+    TUPLE{ request
+        protocol: https
+        method: "GET"
+        host: "www.amazon.com"
+        port: 443
+        path: "/index.html"
+        version: "1.1"
+        cookies: V{ }
+        header: H{ { "connection" "close" } }
+    }
+] [
+    [
+        "https://www.amazon.com/index.html"
+        <get-request>
+    ] with-scope
+] unit-test
index 17882277a3bdb66578fc7d89d321042a27e764e1..cec1bb931a014748176e265f124209f8ed1dfca2 100755 (executable)
@@ -19,22 +19,8 @@ DEFER: http-request
 
 <PRIVATE
 
-: parse-url ( url -- resource host port )
-    "http://" ?head [ "Only http:// supported" throw ] unless
-    "/" split1 [ "/" prepend ] [ "/" ] if*
-    swap parse-host ;
-
-: store-path ( request path -- request )
-    "?" split1 >r >>path r> dup [ query>assoc ] when >>query ;
-
-: request-with-url ( request url -- request )
-    parse-url >r >r store-path r> >>host r> >>port ;
-
 SYMBOL: redirects
 
-: absolute-url? ( url -- ? )
-    [ "http://" head? ] [ "https://" head? ] bi or ;
-
 : do-redirect ( response data -- response data )
     over code>> 300 399 between? [
         drop
@@ -42,7 +28,7 @@ SYMBOL: redirects
         redirects get max-redirects < [
             request get
             swap "location" header dup absolute-url?
-            [ request-with-url ] [ store-path ] if
+            [ request-with-url ] [ request-with-path ] if
             "GET" >>method http-request
         ] [
             too-many-redirects
index 968d4d88ca16735ee57d358e6a741f0131102054..bbbebda53a81a7816d936b0305d23296c1f52ce7 100755 (executable)
@@ -7,7 +7,7 @@ strings vectors hashtables quotations arrays byte-arrays
 math.parser calendar calendar.format
 
 io io.streams.string io.encodings.utf8 io.encodings.string
-io.sockets
+io.sockets io.sockets.secure
 
 unicode.case unicode.categories qualified ;
 
@@ -15,9 +15,31 @@ EXCLUDE: fry => , ;
 
 IN: http
 
-: http-port 80 ; inline
+SINGLETON: http
 
-: https-port 443 ; inline
+SINGLETON: https
+
+GENERIC: http-port ( protocol -- port )
+
+M: http http-port drop 80 ;
+
+M: https http-port drop 443 ;
+
+GENERIC: protocol>string ( protocol -- string )
+
+M: http protocol>string drop "http" ;
+
+M: https protocol>string drop "https" ;
+
+: string>protocol ( string -- protocol )
+    {
+        { "http" [ http ] }
+        { "https" [ https ] }
+        [ "Unknown protocol: " swap append throw ]
+    } case ;
+
+: absolute-url? ( url -- ? )
+    [ "http://" head? ] [ "https://" head? ] bi or ;
 
 : url-quotable? ( ch -- ? )
     #! In a URL, can this character be used without
@@ -212,6 +234,7 @@ TUPLE: cookie name value path domain expires max-age http-only ;
     [ unparse-cookie ] map concat "; " join ;
 
 TUPLE: request
+protocol
 host
 port
 method
@@ -229,7 +252,7 @@ cookies ;
 : <request>
     request new
         "1.1" >>version
-        http-port >>port
+        http >>protocol
         H{ } clone >>header
         H{ } clone >>query
         V{ } clone >>cookies
@@ -242,6 +265,7 @@ cookies ;
     pick query>> set-at ;
 
 : chop-hostname ( str -- str' )
+    ":" split1 nip
     CHAR: / over index over length or tail
     dup empty? [ drop "/" ] when ;
 
@@ -249,7 +273,9 @@ cookies ;
     #! Technically, only proxies are meant to support hostnames
     #! in HTTP requests, but IE sends these sometimes so we
     #! just chop the hostname part.
-    url-decode "http://" ?head [ chop-hostname ] when ;
+    url-decode
+    dup { "http://" "https://" } [ head? ] with contains?
+    [ chop-hostname ] when ;
 
 : read-method ( request -- request )
     " " read-until [ "Bad request: method" throw ] unless
@@ -298,10 +324,11 @@ SYMBOL: max-post-request
 
 : parse-host ( string -- host port )
     "." ?tail drop ":" split1
-    [ string>number ] [ http-port ] if* ;
+    dup [ string>number ] when ;
 
 : extract-host ( request -- request )
-    dup "host" header parse-host >r >>host r> >>port ;
+    dup [ "host" header parse-host ] keep protocol>> http-port or
+    [ >>host ] [ >>port ] bi* ;
 
 : extract-post-data-type ( request -- request )
     dup "content-type" header >>post-data-type ;
@@ -314,7 +341,7 @@ SYMBOL: max-post-request
     dup "cookie" header [ parse-cookies >>cookies ] when* ;
 
 : parse-content-type-attributes ( string -- attributes )
-    " " split [ empty? not ] filter [ "=" split1 >r >lower r> ] { } map>assoc ;
+    " " split harvest [ "=" split1 >r >lower r> ] { } map>assoc ;
 
 : parse-content-type ( content-type -- type encoding )
     ";" split1 parse-content-type-attributes "charset" swap at ;
@@ -353,12 +380,20 @@ SYMBOL: max-post-request
         "application/x-www-form-urlencoded" >>post-data-type
     ] if ;
 
+GENERIC: protocol-addr ( request protocol -- addr )
+
+M: object protocol-addr
+    drop [ host>> ] [ port>> ] bi <inet> ;
+
+M: https protocol-addr
+    call-next-method <ssl> ;
+
 : request-addr ( request -- addr )
-    [ host>> ] [ port>> ] bi <inet> ;
+    dup protocol>> protocol-addr ;
 
 : request-host ( request -- string )
-    [ host>> ] [ port>> ] bi
-    dup 80 = [ drop ] [ ":" swap number>string 3append ] if ;
+    [ host>> ] [ port>> ] bi dup http http-port =
+    [ drop ] [ ":" swap number>string 3append ] if ;
 
 : write-request-header ( request -- request )
     dup header>> >hashtable
@@ -381,13 +416,32 @@ SYMBOL: max-post-request
     flush
     drop ;
 
+: request-with-path ( request path -- request )
+    [ "/" prepend ] [ "/" ] if*
+    "?" split1 [ >>path ] [ dup [ query>assoc ] when >>query ] bi* ;
+
+: request-with-url ( request url -- request )
+    ":" split1
+    [ string>protocol >>protocol ]
+    [
+        "//" ?head [ "Invalid URL" throw ] unless
+        "/" split1
+        [
+            parse-host [ >>host ] [ >>port ] bi*
+            dup protocol>> http-port '[ , or ] change-port
+        ]
+        [ request-with-path ]
+        bi*
+    ] bi* ;
+
 : request-url ( request -- url )
     [
         [
             dup host>> [
-                [ "http://" write host>> url-encode write ]
-                [ ":" write port>> number>string write ]
-                bi
+                [ protocol>> protocol>string write "://" write ]
+                [ host>> url-encode write ":" write ]
+                [ port>> number>string write ]
+                tri
             ] [ drop ] if
         ]
         [ path>> "/" head? [ "/" write ] unless ]
index 70c1e9a1f56abf5c0d029d6a4b600836ca6a5ed2..4e561220f9b9e304cbd1b1169e1cb9343bca785e 100755 (executable)
@@ -240,7 +240,7 @@ SYMBOL: exit-continuation
     '[ exit-continuation set @ ] callcc1 exit-continuation off ;
 
 : split-path ( string -- path )
-    "/" split [ empty? not ] filter ;
+    "/" split harvest ;
 
 : init-request ( -- )
     H{ } clone base-paths set
index aecae1cf881d92102d29cfb6763e3896c55dc837..4194ff6609880903c59583c98e0467e5a3a39e04 100755 (executable)
@@ -148,7 +148,7 @@ DEFER: (d)
 : nth-basis-elt ( generators n -- elt )
     over length [
         3dup bit? [ nth ] [ 2drop f ] if
-    ] map [ ] filter 2nip ;
+    ] map sift 2nip ;
 
 : basis ( generators -- seq )
     natural-sort dup length 2^ [ nth-basis-elt ] with map ;
index 3bc8637f9061a41cd693a4f7458d113dc22a9231..a832b10a18a05c02be7905724e674bfbc8a8ce71 100755 (executable)
@@ -37,7 +37,7 @@ SYMBOL: log-files
     write bl write ": " write print ;\r
 \r
 : write-message ( msg word-name level -- )\r
-    rot [ empty? not ] filter {\r
+    rot harvest {\r
         { [ dup empty? ] [ 3drop ] }\r
         { [ dup length 1 = ] [ first -rot f (write-message) ] }\r
         [\r
index 3da676dcb2eb1757e260cfa2efd8404803ac2d4b..7ab7e83d124da616178174508a36e4205e5e7a53 100755 (executable)
@@ -17,14 +17,14 @@ MEMO: any-char-parser ( -- parser )
 
 : search ( string parser -- seq )
   any-char-parser [ drop f ] action 2array choice repeat0 parse dup [
-    parse-result-ast [ ] filter
+    parse-result-ast sift
   ] [
     drop { }
   ] if ;
 
 
 : (replace) ( string parser -- seq )
-  any-char-parser 2array choice repeat0 parse parse-result-ast [ ] filter ;
+  any-char-parser 2array choice repeat0 parse parse-result-ast sift ;
 
 : replace ( string parser -- result )
  [  (replace) [ tree-write ] each ] with-string-writer ;
index 0dc5601cd011279d7129d9285bce501a533147bb..b703bb55a01499c39d2ef951e1c17910a7a9f099 100755 (executable)
@@ -216,7 +216,7 @@ USE: continuations
   >r dup length swap r>
   [ = [ ] [ drop f ] if ] curry
   2map
-  [ ] filter ;
+  sift ;
 
 <PRIVATE
 : (attempt-each-integer) ( i n quot -- result )
index 2b28e158df360697e4fa8da64eec5d8bb2a3aa00..86035ae1a487768a76cc5e32fa463e054600fc29 100755 (executable)
@@ -106,7 +106,7 @@ C: <vocab-author> vocab-author
 : vocab-xref ( vocab quot -- vocabs )
     >r dup vocab-name swap words r> map
     [ [ word? ] filter [ word-vocabulary ] map ] map>set
-    remove [ ] filter [ vocab ] map ; inline
+    remove sift [ vocab ] map ; inline
 
 : vocab-uses ( vocab -- vocabs ) [ uses ] vocab-xref ;
 
index 56a0fbc3ee5cc148a42355db22ba22ffc8afe297..cf97bedb8dee257b30d7825479d21c0dc5c8e952 100644 (file)
@@ -8,7 +8,7 @@ TUPLE: track sizes ;
 
 : normalized-sizes ( track -- seq )
     track-sizes
-    [ [ ] filter sum ] keep [ dup [ over / ] when ] map nip ;
+    [ sift sum ] keep [ dup [ over / ] when ] map nip ;
 
 : <track> ( orientation -- track )
     <pack> V{ } clone
index 6d22083096d5e98fbd79840606f7ea0c0c0031f0..47b0d5170582f27d75055411238dd9b099e5c25a 100755 (executable)
@@ -17,7 +17,7 @@ IN: ui.tools.tests
 [ ] [ "w" get com-scroll-down ] unit-test
 [ t ] [
     "w" get workspace-book gadget-children
-    [ tool-scroller ] map [ ] filter [ scroller? ] all?
+    [ tool-scroller ] map sift [ scroller? ] all?
 ] unit-test
 [ ] [ "w" get hide-popup ] unit-test
 [ ] [ <gadget> "w" get show-popup ] unit-test
index dfac27f7a4df3315d8768809deab7df537ca7412..53f81ccbf9b11514cba04e8014d82531b7c5829b 100755 (executable)
@@ -24,8 +24,7 @@ CATEGORY: grapheme-control Zl Zp Cc Cf ;
     [ blank? ] right-trim ;
 
 : process-other-extend ( lines -- set )
-    [ "#" split1 drop ";" split1 drop trim-blank ] map
-    [ empty? not ] filter
+    [ "#" split1 drop ";" split1 drop trim-blank ] map harvest
     [ ".." split1 [ dup ] unless* [ hex> ] bi@ [a,b] ] map
     concat unique ;
 
index 52706647a92fee01c8fb4d895cfba11d65dc0a5f..b411e4e2099c28951cf09934d1bf32e6c872ef6f 100755 (executable)
@@ -89,7 +89,7 @@ IN: unicode.data
     ] assoc-map >hashtable ;
 
 : multihex ( hexstring -- string )
-    " " split [ hex> ] map [ ] filter ;
+    " " split [ hex> ] map sift ;
 
 TUPLE: code-point lower title upper ;
 
index 846f797f713c47a2908508ed924b3bcfab5701cf..2d07ba2caafbccae7c8159d4000c195d18ac99e9 100755 (executable)
@@ -10,7 +10,7 @@ SYMBOL: interned
 
 : parse-script ( stream -- assoc )
     ! assoc is code point/range => name
-    lines [ "#" split1 drop ] map [ empty? not ] filter [
+    lines [ "#" split1 drop ] map harvest [
         ";" split1 [ [ blank? ] trim ] bi@
     ] H{ } map>assoc ;
 
index b3c803be2d863185bd57cbea3f94c848b6bf4f28..b63a5c333796eda71cf87e071ac4bcf13ef82f07 100755 (executable)
@@ -45,8 +45,7 @@ unless
     <com-function-definition> ;
 
 : parse-com-functions ( -- functions )
-    ";" parse-tokens { ")" } split
-    [ empty? not ] filter
+    ";" parse-tokens { ")" } split harvest
     [ (parse-com-function) ] map ;
 
 : (iid-word) ( definition -- word )
index 9b1eeede96690b38b7fb5c9d176475d0d7cc2c8b..29a8bbf10fa881c3e004d9b329006006cf48eaf6 100644 (file)
@@ -8,7 +8,7 @@ IN: wrap
 SYMBOL: width
 
 : line-chunks ( string -- words-lines )
-    "\n" split [ " \t" split [ empty? not ] filter ] map ;
+    "\n" split [ " \t" split harvest ] map ;
 
 : (split-chunk) ( words -- )
     -1 over [ length + 1+ dup width get > ] find drop nip