Merge branch 'master' of git://factorcode.org/git/factor
commit
29a0a7375a
|
@ -29,10 +29,8 @@ $nl
|
||||||
{ $subsection heap-pop* }
|
{ $subsection heap-pop* }
|
||||||
{ $subsection heap-pop }
|
{ $subsection heap-pop }
|
||||||
{ $subsection heap-delete }
|
{ $subsection heap-delete }
|
||||||
$nl
|
|
||||||
"Processing heaps:"
|
"Processing heaps:"
|
||||||
{ $subsection slurp-heap }
|
{ $subsection slurp-heap } ;
|
||||||
{ $subsection slurp-heap-when } ;
|
|
||||||
|
|
||||||
ABOUT: "heaps"
|
ABOUT: "heaps"
|
||||||
|
|
||||||
|
@ -91,8 +89,3 @@ HELP: slurp-heap
|
||||||
{ $values
|
{ $values
|
||||||
{ "heap" "a heap" } { "quot" quotation } }
|
{ "heap" "a heap" } { "quot" quotation } }
|
||||||
{ $description "Removes values from a heap and processes them with the quotation until the heap is empty." } ;
|
{ $description "Removes values from a heap and processes them with the quotation until the heap is empty." } ;
|
||||||
|
|
||||||
HELP: slurp-heap-when
|
|
||||||
{ $values
|
|
||||||
{ "heap" "a heap" } { "quot1" quotation } { "quot2" quotation } }
|
|
||||||
{ $description "Removes values from a heap that match the predicate quotation " { $snippet "quot1" } " and processes them with " { $snippet "quot2" } " until the predicate quotation no longer matches." } ;
|
|
||||||
|
|
|
@ -195,9 +195,3 @@ M: heap heap-pop ( heap -- value key )
|
||||||
over heap-empty? [ 2drop ] [
|
over heap-empty? [ 2drop ] [
|
||||||
[ [ heap-pop drop ] dip call ] [ slurp-heap ] 2bi
|
[ [ heap-pop drop ] dip call ] [ slurp-heap ] 2bi
|
||||||
] if ; inline recursive
|
] if ; inline recursive
|
||||||
|
|
||||||
: slurp-heap-when ( heap quot1 quot2: ( value key -- ) -- )
|
|
||||||
pick heap-empty? [ 3drop ] [
|
|
||||||
[ [ heap-pop dup ] 2dip slip [ t ] compose [ 2drop f ] if ]
|
|
||||||
[ roll [ slurp-heap-when ] [ 3drop ] if ] 3bi
|
|
||||||
] if ; inline recursive
|
|
||||||
|
|
|
@ -22,6 +22,11 @@ HELP: spider
|
||||||
HELP: spider-result
|
HELP: spider-result
|
||||||
{ $description "" } ;
|
{ $description "" } ;
|
||||||
|
|
||||||
|
HELP: slurp-heap-when
|
||||||
|
{ $values
|
||||||
|
{ "heap" "a heap" } { "quot1" quotation } { "quot2" quotation } }
|
||||||
|
{ $description "Removes values from a heap that match the predicate quotation " { $snippet "quot1" } " and processes them with " { $snippet "quot2" } " until the predicate quotation no longer matches." } ;
|
||||||
|
|
||||||
ARTICLE: "spider-tutorial" "Spider tutorial"
|
ARTICLE: "spider-tutorial" "Spider tutorial"
|
||||||
"To create a new spider, call the " { $link <spider> } " word with a link to the site you wish to spider."
|
"To create a new spider, call the " { $link <spider> } " word with a link to the site you wish to spider."
|
||||||
{ $code <" "http://concatentative.org" <spider> "> }
|
{ $code <" "http://concatentative.org" <spider> "> }
|
||||||
|
|
|
@ -82,6 +82,12 @@ links processing-time timestamp ;
|
||||||
[ initial-links>> normalize-hrefs 0 ] keep
|
[ initial-links>> normalize-hrefs 0 ] keep
|
||||||
[ add-todo ] keep ;
|
[ add-todo ] keep ;
|
||||||
|
|
||||||
|
: slurp-heap-when ( heap quot1 quot2: ( value key -- ) -- )
|
||||||
|
pick heap-empty? [ 3drop ] [
|
||||||
|
[ [ heap-pop dup ] 2dip slip [ t ] compose [ 2drop f ] if ]
|
||||||
|
[ roll [ slurp-heap-when ] [ 3drop ] if ] 3bi
|
||||||
|
] if ; inline recursive
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
: run-spider ( spider -- spider )
|
: run-spider ( spider -- spider )
|
||||||
|
|
|
@ -22,10 +22,9 @@ IN: suffix-arrays
|
||||||
: <funky-slice> ( from/f to/f seq -- slice )
|
: <funky-slice> ( from/f to/f seq -- slice )
|
||||||
[
|
[
|
||||||
tuck
|
tuck
|
||||||
[ drop [ 0 ] unless* ]
|
[ drop 0 or ] [ length or ] 2bi*
|
||||||
[ dupd length ? ] 2bi*
|
|
||||||
[ min ] keep
|
[ min ] keep
|
||||||
] keep <slice> ;
|
] keep <slice> ; inline
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
|
@ -35,6 +34,6 @@ PRIVATE>
|
||||||
: SA{ \ } [ >suffix-array ] parse-literal ; parsing
|
: SA{ \ } [ >suffix-array ] parse-literal ; parsing
|
||||||
|
|
||||||
: query ( begin suffix-array -- matches )
|
: query ( begin suffix-array -- matches )
|
||||||
2dup find-index
|
2dup find-index dup
|
||||||
[ -rot [ from-to ] keep <funky-slice> [ seq>> ] map prune ]
|
[ -rot [ from-to ] keep <funky-slice> [ seq>> ] map prune ]
|
||||||
[ 2drop { } ] if* ;
|
[ 3drop { } ] if ;
|
||||||
|
|
Loading…
Reference in New Issue