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