Documentation updates and cleanups

db4
Slava Pestov 2008-04-14 05:19:26 -05:00
parent 70bec926d0
commit 31a9954530
13 changed files with 34 additions and 24 deletions

View File

@ -76,7 +76,7 @@ ARTICLE: "assocs-sets" "Set-theoretic operations on assocs"
{ $subsection remove-all } { $subsection remove-all }
{ $subsection substitute } { $subsection substitute }
{ $subsection substitute-here } { $subsection substitute-here }
{ $see-also key? } ; { $see-also key? assoc-contains? assoc-all? "sets" } ;
ARTICLE: "assocs-mutation" "Storing keys and values in assocs" ARTICLE: "assocs-mutation" "Storing keys and values in assocs"
"Utility operations built up from the " { $link "assocs-protocol" } ":" "Utility operations built up from the " { $link "assocs-protocol" } ":"
@ -97,6 +97,7 @@ $nl
{ $subsection assoc-map } { $subsection assoc-map }
{ $subsection assoc-push-if } { $subsection assoc-push-if }
{ $subsection assoc-subset } { $subsection assoc-subset }
{ $subsection assoc-contains? }
{ $subsection assoc-all? } { $subsection assoc-all? }
"Three additional combinators:" "Three additional combinators:"
{ $subsection cache } { $subsection cache }
@ -206,9 +207,13 @@ HELP: assoc-subset
{ $values { "assoc" assoc } { "quot" "a quotation with stack effect " { $snippet "( key value -- ? )" } } { "subassoc" "a new assoc" } } { $values { "assoc" assoc } { "quot" "a quotation with stack effect " { $snippet "( key value -- ? )" } } { "subassoc" "a new assoc" } }
{ $description "Outputs an assoc of the same type as " { $snippet "assoc" } " consisting of all entries for which the predicate quotation yields true." } ; { $description "Outputs an assoc of the same type as " { $snippet "assoc" } " consisting of all entries for which the predicate quotation yields true." } ;
HELP: assoc-contains?
{ $values { "assoc" assoc } { "quot" "a quotation with stack effect " { $snippet "( key value -- ? )" } } { "?" "a boolean" } }
{ $description "Tests if the assoc contains an entry satisfying a predicate by applying the quotation to each entry in turn. Iteration stops if an entry is found for which the quotation outputs a true value." } ;
HELP: assoc-all? HELP: assoc-all?
{ $values { "assoc" assoc } { "quot" "a quotation with stack effect " { $snippet "( key value -- ? )" } } { "?" "a boolean" } } { $values { "assoc" assoc } { "quot" "a quotation with stack effect " { $snippet "( key value -- ? )" } } { "?" "a boolean" } }
{ $description "Applies a predicate quotation to entry in the assoc. Outputs true if the assoc yields true for each entry (which includes the case where the assoc is empty)." } ; { $description "Tests if all entries in the assoc satisfy a predicate by applying the quotation to each entry in turn. a predicate quotation to entry in the assoc. Iteration stops if an entry is found for which the quotation outputs " { $link f } ". If the assoc is empty, always outputs " { $link t } "." } ;
HELP: subassoc? HELP: subassoc?
{ $values { "assoc1" assoc } { "assoc2" assoc } { "?" "a new assoc" } } { $values { "assoc1" assoc } { "assoc2" assoc } { "?" "a new assoc" } }

View File

@ -528,12 +528,7 @@ HELP: contains?
HELP: all? HELP: all?
{ $values { "seq" sequence } { "quot" "a quotation with stack effect " { $snippet "( elt -- ? )" } } { "?" "a boolean" } } { $values { "seq" sequence } { "quot" "a quotation with stack effect " { $snippet "( elt -- ? )" } } { "?" "a boolean" } }
{ $description "Tests if all elements in the sequence satisfy the predicate by checking each element in turn. Given an empty sequence, vacuously outputs " { $link t } "." } { $description "Tests if all elements in the sequence satisfy the predicate by checking each element in turn. Given an empty sequence, vacuously outputs " { $link t } "." } ;
{ $notes
"The implementation makes use of a well-known logical identity:"
$nl
{ $snippet "P[x] for all x <==> not ((not P[x]) for some x)" }
} ;
HELP: push-if HELP: push-if
{ $values { "elt" object } { "quot" "a quotation with stack effect " { $snippet "( elt -- ? )" } } { "accum" "a resizable mutable sequence" } } { $values { "elt" object } { "quot" "a quotation with stack effect " { $snippet "( elt -- ? )" } } { "accum" "a resizable mutable sequence" } }

2
core/sets/authors.txt Normal file
View File

@ -0,0 +1,2 @@
Slava Pestov
Doug Coleman

View File

@ -1,7 +1,9 @@
USING: kernel help.markup help.syntax sequences ; USING: kernel help.markup help.syntax sequences ;
IN: sets IN: sets
ARTICLE: "sets" "Set theoretic operations" ARTICLE: "sets" "Set-theoretic operations on sequences"
"Set-theoretic operations on sequences are defined on the " { $vocab-link "sets" } " vocabulary. These operations use hashtables internally to achieve linear running time."
$nl
"Remove duplicates:" "Remove duplicates:"
{ $subsection prune } { $subsection prune }
"Test for duplicates:" "Test for duplicates:"
@ -9,7 +11,8 @@ ARTICLE: "sets" "Set theoretic operations"
"Set operations on sequences:" "Set operations on sequences:"
{ $subsection diff } { $subsection diff }
{ $subsection intersect } { $subsection intersect }
{ $subsection union } ; { $subsection union }
{ $see-also member? memq? contains? all? "assocs-sets" } ;
HELP: unique HELP: unique
{ $values { "seq" "a sequence" } { "assoc" "an assoc" } } { $values { "seq" "a sequence" } { "assoc" "an assoc" } }

1
core/sets/summary.txt Normal file
View File

@ -0,0 +1 @@
Set-theoretic operations on sequences

1
core/sets/tags.txt Normal file
View File

@ -0,0 +1 @@
collections

View File

@ -56,13 +56,16 @@ mailbox variables sleep-entry ;
PRIVATE> PRIVATE>
: <thread> ( quot name -- thread ) : new-thread ( quot name class -- thread )
\ thread new new
swap >>name swap >>name
swap >>quot swap >>quot
\ thread counter >>id \ thread counter >>id
<box> >>continuation <box> >>continuation
[ ] >>exit-handler ; [ ] >>exit-handler ; inline
: <thread> ( quot name -- thread )
\ thread new-thread ;
: run-queue 42 getenv ; : run-queue 42 getenv ;

View File

@ -0,0 +1 @@
Non-core array words

View File

@ -81,23 +81,19 @@ M: mailbox dispose
: wait-for-close ( mailbox -- ) : wait-for-close ( mailbox -- )
f wait-for-close-timeout ; f wait-for-close-timeout ;
TUPLE: linked-error thread ; TUPLE: linked-error error thread ;
: <linked-error> ( error thread -- linked ) C: <linked-error> linked-error
{ set-delegate set-linked-error-thread }
linked-error construct ;
: ?linked dup linked-error? [ rethrow ] when ; : ?linked dup linked-error? [ rethrow ] when ;
TUPLE: linked-thread supervisor ; TUPLE: linked-thread < thread supervisor ;
M: linked-thread error-in-thread M: linked-thread error-in-thread
[ <linked-error> ] keep [ <linked-error> ] [ supervisor>> ] bi mailbox-put ;
linked-thread-supervisor mailbox-put ;
: <linked-thread> ( quot name mailbox -- thread' ) : <linked-thread> ( quot name mailbox -- thread' )
>r <thread> linked-thread construct-delegate r> >r linked-thread new-thread r> >>supervisor ;
over set-linked-thread-supervisor ;
: spawn-linked-to ( quot name mailbox -- thread ) : spawn-linked-to ( quot name mailbox -- thread )
<linked-thread> [ (spawn) ] keep ; <linked-thread> [ (spawn) ] keep ;

View File

@ -3,7 +3,7 @@ namespaces words sequences classes assocs vocabs kernel arrays
prettyprint.backend kernel.private io generic math system prettyprint.backend kernel.private io generic math system
strings sbufs vectors byte-arrays bit-arrays float-arrays strings sbufs vectors byte-arrays bit-arrays float-arrays
quotations io.streams.byte-array io.encodings.string quotations io.streams.byte-array io.encodings.string
classes.builtin ; classes.builtin parser ;
IN: help.handbook IN: help.handbook
ARTICLE: "conventions" "Conventions" ARTICLE: "conventions" "Conventions"
@ -25,6 +25,7 @@ $nl
{ { $snippet { $emphasis "foo" } "?" } "outputs a boolean" { { $link empty? } } } { { $snippet { $emphasis "foo" } "?" } "outputs a boolean" { { $link empty? } } }
{ { $snippet "?" { $emphasis "foo" } } { "conditionally performs " { $snippet { $emphasis "foo" } } } { { $links ?nth } } } { { $snippet "?" { $emphasis "foo" } } { "conditionally performs " { $snippet { $emphasis "foo" } } } { { $links ?nth } } }
{ { $snippet "<" { $emphasis "foo" } ">" } { "creates a new " { $snippet "foo" } } { { $link <array> } } } { { $snippet "<" { $emphasis "foo" } ">" } { "creates a new " { $snippet "foo" } } { { $link <array> } } }
{ { $snippet "new-" { $emphasis "foo" } } { "creates a new " { $snippet "foo" } ", taking some kind of parameter from the stack which determines the type of the object to be created" } { { $link new-sequence } ", " { $link new-lexer } ", " { $link new } } }
{ { $snippet { $emphasis "foo" } "*" } { "alternative form of " { $snippet "foo" } ", or a generic word called by " { $snippet "foo" } } { { $links at* pprint* } } } { { $snippet { $emphasis "foo" } "*" } { "alternative form of " { $snippet "foo" } ", or a generic word called by " { $snippet "foo" } } { { $links at* pprint* } } }
{ { $snippet "(" { $emphasis "foo" } ")" } { "implementation detail word used by " { $snippet "foo" } } { { $link (clone) } } } { { $snippet "(" { $emphasis "foo" } ")" } { "implementation detail word used by " { $snippet "foo" } } { { $link (clone) } } }
{ { $snippet "set-" { $emphasis "foo" } } { "sets " { $snippet "foo" } " to a new value" } { $links set-length } } { { $snippet "set-" { $emphasis "foo" } } { "sets " { $snippet "foo" } " to a new value" } { $links set-length } }

View File

@ -0,0 +1 @@
Non-core sequence words

View File

@ -0,0 +1 @@
Iteration with access to next element

View File

@ -1 +1 @@
Splay Trees Splay trees