docs: change ``{ $quotation "( x -- y )" }`` to ``{ $quotation ( x -- y ) }``.
parent
0b390cc6f2
commit
98935b7f15
|
@ -2,7 +2,7 @@ IN: binary-search
|
|||
USING: help.markup help.syntax sequences kernel math.order ;
|
||||
|
||||
HELP: search
|
||||
{ $values { "seq" "a sorted sequence" } { "quot" { $quotation "( elt -- <=> )" } } { "i" "an index, or " { $link f } } { "elt" "an element, or " { $link f } } }
|
||||
{ $values { "seq" "a sorted sequence" } { "quot" { $quotation ( elt -- <=> ) } } { "i" "an index, or " { $link f } } { "elt" "an element, or " { $link f } } }
|
||||
{ $description "Performs a binary search on a sequence, calling the quotation to decide whether to end the search (" { $link +eq+ } "), search lower (" { $link +lt+ } ") or search higher (" { $link +gt+ } ")."
|
||||
$nl
|
||||
"If the sequence is non-empty, outputs the index and value of the closest match, which is either an element for which the quotation output " { $link +eq+ } ", or failing that, least element for which the quotation output " { $link +lt+ } "."
|
||||
|
|
|
@ -31,7 +31,7 @@ HELP: alien>objc-types
|
|||
{ objc>alien-types alien>objc-types } related-words
|
||||
|
||||
HELP: import-objc-class
|
||||
{ $values { "name" string } { "quot" { $quotation "( -- )" } } }
|
||||
{ $values { "name" string } { "quot" { $quotation ( -- ) } } }
|
||||
{ $description "If a class named " { $snippet "name" } " is already known to the Objective C interface, does nothing. Otherwise, first calls the quotation. The quotation should make the class available to the Objective C runtime if necessary, either by loading a framework or defining it directly. After the quotation returns, this word makes the class available to Factor programs by importing methods and creating a class word the class object in the " { $vocab-link "cocoa.classes" } " vocabulary." } ;
|
||||
|
||||
HELP: root-class
|
||||
|
|
|
@ -228,7 +228,7 @@ HELP: smart-when*
|
|||
|
||||
HELP: smart-with
|
||||
{ $values
|
||||
{ "param" object } { "obj" object } { "quot" { $quotation "( param ..a -- ..b" } } { "curry" curry } }
|
||||
{ "param" object } { "obj" object } { "quot" { $quotation "( param ..a -- ..b )" } } { "curry" curry } }
|
||||
{ $description "A version of " { $link with } " that puts the parameter before any inputs the quotation uses." } ;
|
||||
|
||||
HELP: smart-reduce
|
||||
|
|
|
@ -2,27 +2,27 @@ USING: help.markup help.syntax sequences ;
|
|||
IN: concurrency.combinators
|
||||
|
||||
HELP: parallel-map
|
||||
{ $values { "seq" sequence } { "quot" { $quotation "( elt -- newelt )" } } { "newseq" sequence } }
|
||||
{ $values { "seq" sequence } { "quot" { $quotation ( elt -- newelt ) } } { "newseq" sequence } }
|
||||
{ $description "Spawns a new thread for applying " { $snippet "quot" } " to every element of " { $snippet "seq" } ", collecting the results at the end." }
|
||||
{ $errors "Throws an error if one of the iterations throws an error." } ;
|
||||
|
||||
HELP: 2parallel-map
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( elt1 elt2 -- newelt )" } } { "newseq" sequence } }
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation ( elt1 elt2 -- newelt ) } } { "newseq" sequence } }
|
||||
{ $description "Spawns a new thread for applying " { $snippet "quot" } " to pairwise elements of " { $snippet "seq1" } " and " { $snippet "seq2" } ", collecting the results at the end." }
|
||||
{ $errors "Throws an error if one of the iterations throws an error." } ;
|
||||
|
||||
HELP: parallel-each
|
||||
{ $values { "seq" sequence } { "quot" { $quotation "( elt -- )" } } }
|
||||
{ $values { "seq" sequence } { "quot" { $quotation ( elt -- ) } } }
|
||||
{ $description "Spawns a new thread for applying " { $snippet "quot" } " to every element of " { $snippet "seq" } ", blocking until all quotations complete." }
|
||||
{ $errors "Throws an error if one of the iterations throws an error." } ;
|
||||
|
||||
HELP: 2parallel-each
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( elt1 elt2 -- )" } } }
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation ( elt1 elt2 -- ) } } }
|
||||
{ $description "Spawns a new thread for applying " { $snippet "quot" } " to pairwise elements of " { $snippet "seq1" } " and " { $snippet "seq2" } ", blocking until all quotations complete." }
|
||||
{ $errors "Throws an error if one of the iterations throws an error." } ;
|
||||
|
||||
HELP: parallel-filter
|
||||
{ $values { "seq" sequence } { "quot" { $quotation "( elt -- ? )" } } { "newseq" sequence } }
|
||||
{ $values { "seq" sequence } { "quot" { $quotation ( elt -- ? ) } } { "newseq" sequence } }
|
||||
{ $description "Spawns a new thread for applying " { $snippet "quot" } " to every element of " { $snippet "seq" } ", collecting the elements for which the quotation yielded a true value." }
|
||||
{ $errors "Throws an error if one of the iterations throws an error." } ;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ continuations help.markup help.syntax quotations calendar ;
|
|||
IN: concurrency.futures
|
||||
|
||||
HELP: future
|
||||
{ $values { "quot" { $quotation "( -- value )" } } { "future" future } }
|
||||
{ $values { "quot" { $quotation ( -- value ) } } { "future" future } }
|
||||
{ $description "Creates a deferred computation."
|
||||
$nl
|
||||
"The quotation begins with an empty data stack, an empty catch stack, and a name stack containing the global namespace only. This means that the only way to pass data to the quotation is to partially apply the data, for example using " { $link curry } " or " { $link compose } "." } ;
|
||||
|
|
|
@ -21,7 +21,7 @@ HELP: block-unless-pred
|
|||
{ $values
|
||||
{ "mailbox" mailbox }
|
||||
{ "timeout" "a " { $link duration } " or " { $link f } }
|
||||
{ "pred" { $quotation "( ... message -- ... ? )" } }
|
||||
{ "pred" { $quotation ( ... message -- ... ? ) } }
|
||||
}
|
||||
{ $description "Block the thread if there are no items in the mailbox that return true when the predicate is called with the item on the stack." } ;
|
||||
|
||||
|
@ -40,14 +40,14 @@ HELP: mailbox-get-all
|
|||
{ $description "Blocks the thread if the mailbox is empty, otherwise removes all objects in the mailbox and returns an array containing the objects." } ;
|
||||
|
||||
HELP: while-mailbox-empty
|
||||
{ $values { "mailbox" mailbox }
|
||||
{ "quot" { $quotation "( -- )" } }
|
||||
{ $values { "mailbox" mailbox }
|
||||
{ "quot" { $quotation ( -- ) } }
|
||||
}
|
||||
{ $description "Repeatedly call the quotation while there are no items in the mailbox." } ;
|
||||
|
||||
HELP: mailbox-get?
|
||||
{ $values { "mailbox" mailbox }
|
||||
{ "pred" { $quotation "( obj -- ? )" } }
|
||||
{ $values { "mailbox" mailbox }
|
||||
{ "pred" { $quotation ( obj -- ? ) } }
|
||||
{ "obj" object }
|
||||
}
|
||||
{ $description "Get the first item in the mailbox which satisfies the predicate. When the predicate returns true that item will be returned. If nothing in the mailbox satisfies the predicate then the thread will block until something does." } ;
|
||||
|
|
|
@ -42,7 +42,7 @@ HELP: doc-lines
|
|||
{ $errors "Throws an error if " { $snippet "from" } " or " { $snippet "to" } " is out of bounds." } ;
|
||||
|
||||
HELP: each-line
|
||||
{ $values { "from" "a non-negative integer" } { "to" "a non-negative integer" } { "quot" { $quotation "( ... line -- ... )" } } }
|
||||
{ $values { "from" "a non-negative integer" } { "to" "a non-negative integer" } { "quot" { $quotation ( ... line -- ... ) } } }
|
||||
{ $description "Applies the quotation to each line in the range." }
|
||||
{ $notes "The range is created by calling " { $link <slice> } "." }
|
||||
{ $errors "Throws an error if " { $snippet "from" } " or " { $snippet "to" } " is out of bounds." } ;
|
||||
|
|
|
@ -31,7 +31,7 @@ HELP: os-env
|
|||
} ;
|
||||
|
||||
HELP: change-os-env
|
||||
{ $values { "key" string } { "quot" { $quotation "( old -- new )" } } }
|
||||
{ $values { "key" string } { "quot" { $quotation ( old -- new ) } } }
|
||||
{ $description "Applies a quotation to change the value stored in an environment variable." }
|
||||
{ $examples
|
||||
"This is an operating system-specific feature. On Unix, you can do:"
|
||||
|
|
|
@ -63,7 +63,7 @@ HELP: realm
|
|||
{ $class-description "The class of authentication realms. See " { $link "furnace.auth.realms" } " for details." } ;
|
||||
|
||||
HELP: uchange
|
||||
{ $values { "quot" { $quotation "( old -- new )" } } { "key" symbol } }
|
||||
{ $values { "quot" { $quotation ( old -- new ) } } { "key" symbol } }
|
||||
{ $description "Applies the quotation to the old value of the user profile variable, and assigns the resulting value back to the variable." } ;
|
||||
|
||||
HELP: uget
|
||||
|
|
|
@ -28,7 +28,7 @@ HELP: cset
|
|||
{ $description "Sets the value of a conversation variable." } ;
|
||||
|
||||
HELP: cchange
|
||||
{ $values { "key" symbol } { "quot" { $quotation "( old -- new )" } } }
|
||||
{ $values { "key" symbol } { "quot" { $quotation ( old -- new ) } } }
|
||||
{ $description "Applies the quotation to the old value of the conversation variable, and assigns the resulting value back to the variable." } ;
|
||||
|
||||
ARTICLE: "furnace.conversations" "Furnace conversation scope"
|
||||
|
|
|
@ -11,7 +11,7 @@ HELP: <sessions>
|
|||
{ $description "Wraps a responder in a session manager responder." } ;
|
||||
|
||||
HELP: schange
|
||||
{ $values { "key" symbol } { "quot" { $quotation "( old -- new )" } } }
|
||||
{ $values { "key" symbol } { "quot" { $quotation ( old -- new ) } } }
|
||||
{ $description "Applies the quotation to the old value of the session variable, and assigns the resulting value back to the variable." } ;
|
||||
|
||||
HELP: sget
|
||||
|
|
|
@ -16,7 +16,7 @@ HELP: client-state
|
|||
{ $notes "This word is used by session management, conversation scope and asides." } ;
|
||||
|
||||
HELP: each-responder
|
||||
{ $values { "quot" { $quotation "( responder -- )" } } }
|
||||
{ $values { "quot" { $quotation ( ... responder -- ... ) } } }
|
||||
{ $description "Applies the quotation to each responder involved in processing the current request." } ;
|
||||
|
||||
HELP: hidden-form-field
|
||||
|
@ -88,7 +88,7 @@ HELP: exit-with
|
|||
{ $description "Exits from an outer " { $link with-exit-continuation } "." } ;
|
||||
|
||||
HELP: with-exit-continuation
|
||||
{ $values { "quot" { $quotation { "( -- value )" } } } { "value" "a value returned by the quotation or an " { $link exit-with } " invocation" } }
|
||||
{ $values { "quot" { $quotation ( -- value ) } } { "value" "a value returned by the quotation or an " { $link exit-with } " invocation" } }
|
||||
{ $description "Runs a quotation with the " { $link exit-continuation } " variable bound. Calling " { $link exit-with } " in the quotation will immediately return." }
|
||||
{ $notes "Furnace actions and authentication realms wrap their execution in this combinator, allowing form validation failures and login requests, respectively, to immediately return an HTTP response to the client without running any more responder code." } ;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ ERROR: no-such-word name vocab ;
|
|||
: nested-responders ( -- seq )
|
||||
responder-nesting get values ;
|
||||
|
||||
: each-responder ( quot -- )
|
||||
: each-responder ( quot: ( ... responder -- ... ) -- )
|
||||
nested-responders swap each ; inline
|
||||
|
||||
ERROR: no-such-responder responder ;
|
||||
|
|
|
@ -28,5 +28,5 @@ HELP: remove-vertex
|
|||
{ $side-effects "graph" } ;
|
||||
|
||||
HELP: closure
|
||||
{ $values { "vertex" object } { "quot" { $quotation "( vertex -- assoc )" } } { "assoc" "a new assoc" } }
|
||||
{ $values { "vertex" object } { "quot" { $quotation ( vertex -- assoc ) } } { "assoc" "a new assoc" } }
|
||||
{ $description "Outputs a set of all vertices reachable from " { $snippet "vertex" } " via edges given by the quotation. The set always includes " { $snippet "vertex" } "." } ;
|
||||
|
|
|
@ -153,7 +153,7 @@ HELP: <circular-clumps>
|
|||
{ <clumps> <circular-clumps> <groups> } related-words
|
||||
|
||||
HELP: monotonic?
|
||||
{ $values { "seq" sequence } { "quot" { $quotation "( elt1 elt2 -- ? )" } } { "?" "a boolean" } }
|
||||
{ $values { "seq" sequence } { "quot" { $quotation ( elt1 elt2 -- ? ) } } { "?" "a boolean" } }
|
||||
{ $description "Applies the relation to successive pairs of elements in the sequence, testing for a truth value. The relation should be a transitive relation, such as a total order or an equality relation." }
|
||||
{ $examples
|
||||
"Testing if a sequence is non-decreasing:"
|
||||
|
|
|
@ -340,7 +340,7 @@ HELP: $link
|
|||
} ;
|
||||
|
||||
HELP: textual-list
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation "( elt -- )" } } }
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation ( elt -- ) } } }
|
||||
{ $description "Applies the quotation to each element of the sequence, printing a comma between each pair of elements." }
|
||||
{ $examples
|
||||
{ $example "USING: help.markup io namespaces ;" "last-element off" "{ \"fish\" \"chips\" \"salt\" } [ write ] textual-list" "fish, chips, salt" }
|
||||
|
@ -406,7 +406,7 @@ HELP: $quotation
|
|||
"Produces the text “a quotation with stack effect " { $emphasis "effect" } "”."
|
||||
}
|
||||
{ $examples
|
||||
{ $markup-example { $quotation "( obj -- )" } }
|
||||
{ $markup-example { $quotation ( obj -- ) } }
|
||||
} ;
|
||||
|
||||
HELP: $list
|
||||
|
|
|
@ -43,6 +43,7 @@ M: simple-element print-element [ print-element ] each ;
|
|||
M: string print-element [ write ] ($span) ;
|
||||
M: array print-element unclip execute( arg -- ) ;
|
||||
M: word print-element { } swap execute( arg -- ) ;
|
||||
M: effect print-element present print-element ;
|
||||
M: f print-element drop ;
|
||||
|
||||
: print-element* ( element style -- )
|
||||
|
|
|
@ -25,7 +25,7 @@ HELP: compile-attr
|
|||
|
||||
HELP: CHLOE:
|
||||
{ $syntax "CHLOE: name definition... ;" }
|
||||
{ $values { "name" "the tag name" } { "definition" { $quotation "( tag -- )" } } }
|
||||
{ $values { "name" "the tag name" } { "definition" { $quotation ( tag -- ) } } }
|
||||
{ $description "Defines compilation semantics for the Chloe tag named " { $snippet "tag" } ". The definition body receives a " { $link tag } " on the stack." } ;
|
||||
|
||||
HELP: COMPONENT:
|
||||
|
@ -47,7 +47,7 @@ HELP: [code]
|
|||
{ $description "Compiles the quotation. It will be called when the template is called." } ;
|
||||
|
||||
HELP: process-children
|
||||
{ $values { "tag" tag } { "quot" { $quotation "( compiled-tag -- )" } } }
|
||||
{ $values { "tag" tag } { "quot" { $quotation ( compiled-tag -- ) } } }
|
||||
{ $description "Compiles the tag. The quotation will be applied to the resulting quotation when the template is called." }
|
||||
{ $examples "See " { $link "html.templates.chloe.extend.tags.example" } " for an example which uses this word to implement a custom control flow tag." } ;
|
||||
|
||||
|
|
|
@ -137,11 +137,11 @@ HELP: http-request*
|
|||
{ $description "Sends an HTTP request to an HTTP server, and reads the response." } ;
|
||||
|
||||
HELP: with-http-request
|
||||
{ $values { "request" request } { "quot" { $quotation "( chunk -- )" } } { "response" response } }
|
||||
{ $values { "request" request } { "quot" { $quotation ( chunk -- ) } } { "response" response } }
|
||||
{ $description "A variant of " { $link with-http-request* } " that checks that the response was successful." } ;
|
||||
|
||||
HELP: with-http-request*
|
||||
{ $values { "request" request } { "quot" { $quotation "( chunk -- )" } } { "response" response } }
|
||||
{ $values { "request" request } { "quot" { $quotation ( chunk -- ) } } { "response" response } }
|
||||
{ $description "Sends an HTTP request to an HTTP server, and reads the response incrementally. Chunks of data are passed to the quotation as they are read. Does not throw an error if the HTTP request fails; to do so, call " { $link check-response } " on the " { $snippet "response" } "." } ;
|
||||
|
||||
{ http-request http-request* with-http-request with-http-request* } related-words
|
||||
|
|
|
@ -4,7 +4,7 @@ USING: help.markup help.syntax io.streams.string ;
|
|||
IN: http.server.static
|
||||
|
||||
HELP: <file-responder>
|
||||
{ $values { "root" "a pathname string" } { "hook" { $quotation "( path mime-type -- response )" } } { "responder" file-responder } }
|
||||
{ $values { "root" "a pathname string" } { "hook" { $quotation ( path mime-type -- response ) } } { "responder" file-responder } }
|
||||
{ $description "Creates a file responder which serves content from " { $snippet "path" } " by using the hook to generate a response." } ;
|
||||
|
||||
HELP: <static>
|
||||
|
|
|
@ -18,13 +18,13 @@ HELP: <mapped-file>
|
|||
{ $errors "Throws an error if a memory mapping could not be established." } ;
|
||||
|
||||
HELP: with-mapped-file
|
||||
{ $values { "path" "a pathname string" } { "quot" { $quotation "( mmap -- )" } } }
|
||||
{ $values { "path" "a pathname string" } { "quot" { $quotation ( mmap -- ) } } }
|
||||
{ $contract "Opens a file for read/write access and maps its contents into memory, passing the " { $link mapped-file } " instance to the quotation. The mapped file is disposed of when the quotation returns, or if an error is thrown." }
|
||||
{ $notes "This is a low-level word, because " { $link mapped-file } " objects simply expose their base address and length. Most applications should use " { $link "io.mmap.arrays" } " instead." }
|
||||
{ $errors "Throws an error if a memory mapping could not be established." } ;
|
||||
|
||||
HELP: with-mapped-file-reader
|
||||
{ $values { "path" "a pathname string" } { "quot" { $quotation "( mmap -- )" } } }
|
||||
{ $values { "path" "a pathname string" } { "quot" { $quotation ( mmap -- ) } } }
|
||||
{ $contract "Opens a file for read-only access and maps its contents into memory, passing the " { $link mapped-file } " instance to the quotation. The mapped file is disposed of when the quotation returns, or if an error is thrown." }
|
||||
{ $notes "This is a low-level word, because " { $link mapped-file } " objects simply expose their base address and length. See " { $link "io.mmap.arrays" } " for a discussion of how to access data in a mapped file." }
|
||||
{ $errors "Throws an error if a memory mapping could not be established." } ;
|
||||
|
|
|
@ -26,7 +26,7 @@ HELP: next-change
|
|||
{ $errors "Throws an error if the monitor is closed from another thread." } ;
|
||||
|
||||
HELP: with-monitor
|
||||
{ $values { "path" "a pathname string" } { "recursive?" "a boolean" } { "quot" { $quotation "( monitor -- )" } } }
|
||||
{ $values { "path" "a pathname string" } { "recursive?" "a boolean" } { "quot" { $quotation ( monitor -- ) } } }
|
||||
{ $description "Opens a file system change monitor and passes it to the quotation. Closes the monitor after the quotation returns or throws an error." }
|
||||
{ $errors "Throws an error if the pathname does not exist, if a monitor could not be created or if the platform does not support monitors." } ;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ HELP: return-connection
|
|||
{ $description "Returns a connection to the pool." } ;
|
||||
|
||||
HELP: with-pooled-connection
|
||||
{ $values { "pool" pool } { "quot" { $quotation "( conn -- )" } } }
|
||||
{ $values { "pool" pool } { "quot" { $quotation ( conn -- ) } } }
|
||||
{ $description "Calls a quotation with a pooled connection on the stack. If the quotation returns successfully, the connection is returned to the pool; if the quotation throws an error, the connection is disposed of with " { $link dispose } "." } ;
|
||||
|
||||
HELP: make-connection
|
||||
|
|
|
@ -22,7 +22,7 @@ HELP: cancel-operation
|
|||
{ $contract "Handles a timeout, usually by waking up all threads waiting on the object." } ;
|
||||
|
||||
HELP: with-timeout
|
||||
{ $values { "obj" object } { "quot" { $quotation "( obj -- )" } } }
|
||||
{ $values { "obj" object } { "quot" { $quotation ( obj -- ) } } }
|
||||
{ $description "Applies the quotation to the object. If the object's timeout expires before the quotation returns, " { $link cancel-operation } " is called on the object." } ;
|
||||
|
||||
ARTICLE: "io.timeouts" "I/O timeout protocol"
|
||||
|
|
|
@ -58,22 +58,22 @@ ARTICLE: { "lists.lazy" "manipulation" } "Manipulating lazy lists"
|
|||
} ;
|
||||
|
||||
HELP: lazy-cons
|
||||
{ $values { "car" { $quotation "( -- elt )" } } { "cdr" { $quotation "( -- cons )" } } { "promise" "the resulting cons object" } }
|
||||
{ $values { "car" { $quotation ( -- elt ) } } { "cdr" { $quotation ( -- cons ) } } { "promise" "the resulting cons object" } }
|
||||
{ $description "Constructs a cons object for a lazy list from two quotations. The " { $snippet "car" } " quotation should return the head of the list, and the " { $snippet "cons" } " quotation the tail when called. When " { $link cons } " or " { $link cdr } " are called on the lazy-cons object then the appropriate quotation is called." }
|
||||
{ $see-also cons car cdr nil nil? } ;
|
||||
|
||||
{ 1lazy-list 2lazy-list 3lazy-list } related-words
|
||||
|
||||
HELP: 1lazy-list
|
||||
{ $values { "a" { $quotation "( -- X )" } } { "lazy-cons" "a lazy-cons object" } }
|
||||
{ $values { "a" { $quotation ( -- X ) } } { "lazy-cons" "a lazy-cons object" } }
|
||||
{ $description "Create a lazy list with 1 element. The element is the result of calling the quotation. The quotation is only called when the list element is requested." } ;
|
||||
|
||||
HELP: 2lazy-list
|
||||
{ $values { "a" { $quotation "( -- X )" } } { "b" { $quotation "( -- X )" } } { "lazy-cons" "a lazy-cons object" } }
|
||||
{ $values { "a" { $quotation ( -- X ) } } { "b" { $quotation ( -- X ) } } { "lazy-cons" "a lazy-cons object" } }
|
||||
{ $description "Create a lazy list with 2 elements. The elements are the result of calling the quotations. The quotations are only called when the list elements are requested." } ;
|
||||
|
||||
HELP: 3lazy-list
|
||||
{ $values { "a" { $quotation "( -- X )" } } { "b" { $quotation "( -- X )" } } { "c" { $quotation "( -- X )" } } { "lazy-cons" "a lazy-cons object" } }
|
||||
{ $values { "a" { $quotation ( -- X ) } } { "b" { $quotation ( -- X ) } } { "c" { $quotation ( -- X ) } } { "lazy-cons" "a lazy-cons object" } }
|
||||
{ $description "Create a lazy list with 3 elements. The elements are the result of calling the quotations. The quotations are only called when the list elements are requested." } ;
|
||||
|
||||
HELP: <memoized-cons>
|
||||
|
@ -84,7 +84,7 @@ HELP: <memoized-cons>
|
|||
{ lazy-map ltake lfilter lappend lfrom lfrom-by lconcat lcartesian-product lcartesian-product* lcomp lcomp* lmerge lwhile luntil } related-words
|
||||
|
||||
HELP: lazy-map
|
||||
{ $values { "list" "a cons object" } { "quot" { $quotation "( obj -- X )" } } { "result" "resulting cons object" } }
|
||||
{ $values { "list" "a cons object" } { "quot" { $quotation ( obj -- X ) } } { "result" "resulting cons object" } }
|
||||
{ $description "Perform a similar functionality to that of the " { $link map } " word, but in a lazy manner. No evaluation of the list elements occurs initially but a " { $link <lazy-map-state> } " object is returned which conforms to the list protocol. Calling " { $link car } ", " { $link cdr } " or " { $link nil? } " on this will evaluate elements as required." } ;
|
||||
|
||||
HELP: ltake
|
||||
|
@ -92,15 +92,15 @@ HELP: ltake
|
|||
{ $description "Outputs a lazy list containing the first n items in the list. This is done a lazy manner. No evaluation of the list elements occurs initially but a " { $link <lazy-take> } " object is returned which conforms to the list protocol. Calling " { $link car } ", " { $link cdr } " or " { $link nil? } " on this will evaluate elements as required." } ;
|
||||
|
||||
HELP: lfilter
|
||||
{ $values { "list" "a cons object" } { "quot" { $quotation "( -- X )" } } { "result" "resulting cons object" } }
|
||||
{ $values { "list" "a cons object" } { "quot" { $quotation ( -- X ) } } { "result" "resulting cons object" } }
|
||||
{ $description "Perform a similar functionality to that of the " { $link filter } " word, but in a lazy manner. No evaluation of the list elements occurs initially but a " { $link <lazy-filter> } " object is returned which conforms to the list protocol. Calling " { $link car } ", " { $link cdr } " or " { $link nil? } " on this will evaluate elements as required." } ;
|
||||
|
||||
HELP: lwhile
|
||||
{ $values { "list" "a cons object" } { "quot" { $quotation "( X -- ? )" } } { "result" "resulting cons object" } }
|
||||
{ $values { "list" "a cons object" } { "quot" { $quotation ( x -- ? ) } } { "result" "resulting cons object" } }
|
||||
{ $description "Outputs a lazy list containing the first items in the list as long as " { $snippet "quot" } " evaluates to t. No evaluation of the list elements occurs initially but a " { $link <lazy-while> } " object is returned with conforms to the list protocol. Calling " { $link car } ", " { $link cdr } " or " { $link nil? } " on this will evaluate elements as required." } ;
|
||||
|
||||
HELP: luntil
|
||||
{ $values { "list" "a cons object" } { "quot" { $quotation "( X -- ? )" } } { "result" "resulting cons object" } }
|
||||
{ $values { "list" "a cons object" } { "quot" { $quotation ( x -- ? ) } } { "result" "resulting cons object" } }
|
||||
{ $description "Outputs a lazy list containing the first items in the list until after " { $snippet "quot" } " evaluates to t. No evaluation of the list elements occurs initially but a " { $link <lazy-while> } " object is returned with conforms to the list protocol. Calling " { $link car } ", " { $link cdr } " or " { $link nil? } " on this will evaluate elements as required." } ;
|
||||
|
||||
HELP: lappend
|
||||
|
@ -108,7 +108,7 @@ HELP: lappend
|
|||
{ $description "Perform a similar functionality to that of the " { $link append } " word, but in a lazy manner. No evaluation of the list elements occurs initially but a " { $link <lazy-append> } " object is returned which conforms to the list protocol. Calling " { $link car } ", " { $link cdr } " or " { $link nil? } " on this will evaluate elements as required. Successive calls to " { $link cdr } " will iterate through list1, followed by list2." } ;
|
||||
|
||||
HELP: lfrom-by
|
||||
{ $values { "n" "an integer" } { "quot" { $quotation "( n -- o )" } } { "lazy-from-by" "a lazy list of integers" } }
|
||||
{ $values { "n" "an integer" } { "quot" { $quotation ( n -- o ) } } { "lazy-from-by" "a lazy list of integers" } }
|
||||
{ $description "Return an infinite lazy list of values starting from n, with each successive value being the result of applying quot to the previous value." } ;
|
||||
|
||||
HELP: lfrom
|
||||
|
@ -140,11 +140,11 @@ HELP: lcartesian-product*
|
|||
{ $description "Given a list of lists, return a list containing the cartesian product of those lists." } ;
|
||||
|
||||
HELP: lcomp
|
||||
{ $values { "list" "a list of lists" } { "quot" { $quotation "( seq -- X )" } } { "result" "the resulting list" } }
|
||||
{ $values { "list" "a list of lists" } { "quot" { $quotation ( seq -- X ) } } { "result" "the resulting list" } }
|
||||
{ $description "Get the cartesian product of the lists in " { $snippet "list" } " and call " { $snippet "quot" } " call with each element from the cartesian product on the stack, the result of which is returned in the final " { $snippet "list" } "." } ;
|
||||
|
||||
HELP: lcomp*
|
||||
{ $values { "list" "a list of lists" } { "guards" "a sequence of quotations with stack effect ( seq -- bool )" } { "quot" { $quotation "( seq -- X )" } } { "result" "a list" } }
|
||||
{ $values { "list" "a list of lists" } { "guards" "a sequence of quotations with stack effect ( seq -- bool )" } { "quot" { $quotation ( seq -- X ) } } { "result" "a list" } }
|
||||
{ $description "Get the cartesian product of the lists in " { $snippet "list" } ", filter it by applying each guard quotation to it and call " { $snippet "quot" } " call with each element from the remaining cartesian product items on the stack, the result of which is returned in the final " { $snippet "list" } "." }
|
||||
{ $examples
|
||||
{ $code "{ 1 2 3 } >list { 4 5 6 } >list 2list { [ first odd? ] } [ first2 + ] lcomp*" }
|
||||
|
|
|
@ -127,19 +127,19 @@ HELP: unswons
|
|||
{ leach foldl lmap>array } related-words
|
||||
|
||||
HELP: leach
|
||||
{ $values { "list" list } { "quot" { $quotation "( ... elt -- ... )" } } }
|
||||
{ $values { "list" list } { "quot" { $quotation ( ... elt -- ... ) } } }
|
||||
{ $description "Call the quotation for each item in the list." } ;
|
||||
|
||||
HELP: foldl
|
||||
{ $values { "list" list } { "identity" "an object" } { "quot" { $quotation "( ... prev elt -- ... next )" } } { "result" "the final result" } }
|
||||
{ $values { "list" list } { "identity" "an object" } { "quot" { $quotation ( ... prev elt -- ... next ) } } { "result" "the final result" } }
|
||||
{ $description "Combines successive elements of the list (in a left-associative order) using a binary operation and outputs the final result." } ;
|
||||
|
||||
HELP: foldr
|
||||
{ $values { "list" list } { "identity" "an object" } { "quot" { $quotation "( ... prev elt -- ... next )" } } { "result" "the final result" } }
|
||||
{ $values { "list" list } { "identity" "an object" } { "quot" { $quotation ( ... prev elt -- ... next ) } } { "result" "the final result" } }
|
||||
{ $description "Combines successive elements of the list (in a right-associative order) using a binary operation, and outputs the final result." } ;
|
||||
|
||||
HELP: lmap
|
||||
{ $values { "list" list } { "quot" { $quotation "( ... elt -- ... newelt )" } } { "result" "the final result" } }
|
||||
{ $values { "list" list } { "quot" { $quotation ( ... elt -- ... newelt ) } } { "result" "the final result" } }
|
||||
{ $description "Applies the quotation to each element of the list in order, collecting the new elements into a new list." } ;
|
||||
|
||||
HELP: lreverse
|
||||
|
|
|
@ -53,7 +53,7 @@ HELP: all-permutations
|
|||
} ;
|
||||
|
||||
HELP: each-permutation
|
||||
{ $values { "seq" sequence } { "quot" { $quotation "( ... elt -- ... )" } } }
|
||||
{ $values { "seq" sequence } { "quot" { $quotation ( ... elt -- ... ) } } }
|
||||
{ $description "Applies the quotation to each permutation of " { $snippet "seq" } " in order." } ;
|
||||
|
||||
HELP: inverse-permutation
|
||||
|
@ -98,7 +98,7 @@ HELP: all-combinations
|
|||
}""" } } ;
|
||||
|
||||
HELP: each-combination
|
||||
{ $values { "seq" sequence } { "k" "a non-negative integer" } { "quot" { $quotation "( ... elt -- ... )" } } }
|
||||
{ $values { "seq" sequence } { "k" "a non-negative integer" } { "quot" { $quotation ( ... elt -- ... ) } } }
|
||||
{ $description "Applies the quotation to each combination of " { $snippet "seq" } " choosing " { $snippet "k" } " elements, in order." } ;
|
||||
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ HELP: histogram
|
|||
HELP: histogram-by
|
||||
{ $values
|
||||
{ "seq" sequence }
|
||||
{ "quot" { $quotation "( x -- bin )" } }
|
||||
{ "quot" { $quotation ( x -- bin ) } }
|
||||
{ "hashtable" hashtable }
|
||||
}
|
||||
{ $description "Returns a hashtable where the keys are the elements of the sequence binned by being passed through " { $snippet "quot" } ", and the values are the number of times members of each bin appeared in that sequence." }
|
||||
|
@ -134,7 +134,7 @@ HELP: sorted-histogram
|
|||
|
||||
HELP: sequence>assoc
|
||||
{ $values
|
||||
{ "seq" sequence } { "map-quot" $quotation } { "insert-quot" quotation } { "exemplar" "an exemplar assoc" }
|
||||
{ "seq" sequence } { "map-quot" quotation } { "insert-quot" quotation } { "exemplar" "an exemplar assoc" }
|
||||
{ "assoc" assoc }
|
||||
}
|
||||
{ $description "Iterates over a sequence, allowing elements of the sequence to be added to a newly created " { $snippet "assoc" } ". The " { $snippet "map-quot" } " gets passed each element from the sequence. Its outputs are passed along with the assoc being constructed to the " { $snippet "insert-quot" } ", which can modify the assoc in response." }
|
||||
|
@ -248,7 +248,7 @@ HELP: rescale
|
|||
|
||||
HELP: collect-by
|
||||
{ $values
|
||||
{ "seq" sequence } { "quot" { $quotation "( ... obj -- ... key )" } }
|
||||
{ "seq" sequence } { "quot" { $quotation ( ... obj -- ... key ) } }
|
||||
{ "hashtable" hashtable }
|
||||
}
|
||||
{ $description "Applies a quotation to each element in the input sequence and returns a " { $snippet "hashtable" } " of like elements. The keys of this " { $snippet "hashtable" } " are the output of " { $snippet "quot" } " and the values at each key are the elements that transformed to that key." }
|
||||
|
@ -264,7 +264,7 @@ HELP: collect-by
|
|||
|
||||
HELP: collect-index-by
|
||||
{ $values
|
||||
{ "seq" sequence } { "quot" { $quotation "( ... obj -- ... key )" } }
|
||||
{ "seq" sequence } { "quot" { $quotation ( ... obj -- ... key ) } }
|
||||
{ "hashtable" hashtable }
|
||||
}
|
||||
{ $description "Applies a quotation to each element in the input sequence and returns a " { $snippet "hashtable" } " of like elements. The keys of this " { $snippet "hashtable" } " are the output of " { $snippet "quot" } " and the values at each key are the indices for the elements that transformed to that key." }
|
||||
|
|
|
@ -550,7 +550,7 @@ HELP: v?
|
|||
{ $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs and results when using SIMD types." } ;
|
||||
|
||||
HELP: vif
|
||||
{ $values { "mask" "a sequence of booleans" } { "true-quot" { $quotation "( -- vector )" } } { "false-quot" { $quotation "( -- vector )" } } { "result" "a sequence" } }
|
||||
{ $values { "mask" "a sequence of booleans" } { "true-quot" { $quotation ( -- vector ) } } { "false-quot" { $quotation ( -- vector ) } } { "result" "a sequence" } }
|
||||
{ $description "If all of the elements of " { $snippet "mask" } " are true, " { $snippet "true-quot" } " is called and its output value returned. If all of the elements of " { $snippet "mask" } " are false, " { $snippet "false-quot" } " is called and its output value returned. Otherwise, both quotations are called and " { $snippet "mask" } " is used to select elements from each output as with " { $link v? } "." }
|
||||
{ $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs and results when using SIMD types."
|
||||
$nl
|
||||
|
|
|
@ -15,7 +15,7 @@ HELP: arrow
|
|||
} ;
|
||||
|
||||
HELP: <arrow>
|
||||
{ $values { "model" model } { "quot" { $quotation "( obj -- newobj )" } } { "arrow" "a new " { $link arrow } } }
|
||||
{ $values { "model" model } { "quot" { $quotation ( obj -- newobj ) } } { "arrow" "a new " { $link arrow } } }
|
||||
{ $description "Creates a new instance of " { $link arrow } ". The value of the new arrow model is computed by applying the quotation to the value." }
|
||||
{ $examples "See the example in the documentation for " { $link arrow } "." } ;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ IN: models.arrow.smart
|
|||
USING: help.syntax help.markup models.product ;
|
||||
|
||||
HELP: <smart-arrow>
|
||||
{ $values { "quot" { $quotation "( ... -- output )" } } }
|
||||
{ $values { "quot" { $quotation ( ... -- output ) } } }
|
||||
{ $description "A macro that expands into a form with the stack effect of the quotation. The form constructs a model which applies the quotation to values from an underlying " { $link product } " model having as many components as the quotation has inputs." }
|
||||
{ $examples
|
||||
"A model which adds the values of two existing models:"
|
||||
|
@ -18,4 +18,4 @@ ARTICLE: "models.arrow.smart" "Smart arrow models"
|
|||
"The " { $vocab-link "models.arrow.smart" } " vocabulary generalizes arrows to arbitrary input arity. They're called “smart” because they resemble " { $link "combinators.smart" } "."
|
||||
{ $subsections <smart-arrow> } ;
|
||||
|
||||
ABOUT: "models.arrow.smart"
|
||||
ABOUT: "models.arrow.smart"
|
||||
|
|
|
@ -71,15 +71,15 @@ HELP: ?set-model
|
|||
{ set-model change-model change-model* (change-model) push-model pop-model } related-words
|
||||
|
||||
HELP: change-model
|
||||
{ $values { "model" model } { "quot" { $quotation "( ..a obj -- ..b newobj )" } } }
|
||||
{ $values { "model" model } { "quot" { $quotation ( ..a obj -- ..b newobj ) } } }
|
||||
{ $description "Applies the quotation to the current value of the model to yield a new value, then changes the value of the model to the new value, and calls " { $link model-changed } " on all observers registered with " { $link add-connection } "." } ;
|
||||
|
||||
HELP: change-model*
|
||||
{ $values { "model" model } { "quot" { $quotation "( ..a obj -- ..b )" } } }
|
||||
{ $values { "model" model } { "quot" { $quotation ( ..a obj -- ..b ) } } }
|
||||
{ $description "Applies the quotation to the current value of the model and calls " { $link model-changed } " on all observers registered with " { $link add-connection } " without actually changing the value of the model. This is useful for notifying observers of operations that mutate a value, as in " { $link push-model } " and " { $link pop-model } "." } ;
|
||||
|
||||
HELP: (change-model)
|
||||
{ $values { "model" model } { "quot" { $quotation "( ..a obj -- ..b newobj )" } } }
|
||||
{ $values { "model" model } { "quot" { $quotation ( ..a obj -- ..b newobj ) } } }
|
||||
{ $description "Applies the quotation to the current value of the model to yield a new value, then changes the value of the model to the new value without notifying any observers registered with " { $link add-connection } "." }
|
||||
{ $notes "There are very few reasons for user code to call this word. Instead, call " { $link change-model } ", which notifies observers." } ;
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ HELP: optional
|
|||
HELP: semantic
|
||||
{ $values
|
||||
{ "parser" "a parser" }
|
||||
{ "quot" { $quotation "( object -- ? )" } }
|
||||
{ "quot" { $quotation ( object -- ? ) } }
|
||||
}
|
||||
{ $description
|
||||
"Returns a parser that succeeds if the 'p1' parser succeeds and the quotation called with "
|
||||
|
@ -130,7 +130,7 @@ HELP: ensure-not
|
|||
HELP: action
|
||||
{ $values
|
||||
{ "parser" "a parser" }
|
||||
{ "quot" { $quotation "( ast -- ast )" } }
|
||||
{ "quot" { $quotation ( ast -- ast ) } }
|
||||
}
|
||||
{ $description
|
||||
"Returns a parser that calls the 'p1' parser and applies the quotation to the AST resulting "
|
||||
|
|
|
@ -33,7 +33,7 @@ HELP: nesting-limit?
|
|||
$prettyprinting-note ;
|
||||
|
||||
HELP: check-recursion
|
||||
{ $values { "obj" "an object" } { "quot" { $quotation "( obj -- )" } } }
|
||||
{ $values { "obj" "an object" } { "quot" { $quotation ( obj -- ) } } }
|
||||
{ $description "If the object is already being printed, that is, if the prettyprinter has encountered a cycle in the object graph, or if the maximum nesting depth has been reached, outputs a dummy string. Otherwise applies the quotation to the object." }
|
||||
$prettyprinting-note ;
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ HELP: save-end-position
|
|||
{ $description "Save the current position as the end position of the block." } ;
|
||||
|
||||
HELP: pprint-sections
|
||||
{ $values { "block" block } { "advancer" { $quotation "( block -- )" } } }
|
||||
{ $values { "block" block } { "advancer" { $quotation ( block -- ) } } }
|
||||
{ $description "Prints child sections of a block, ignoring any " { $link line-break } " sections. The " { $snippet "advancer" } " quotation is called between every pair of sections." } ;
|
||||
|
||||
HELP: do-break
|
||||
|
@ -156,7 +156,7 @@ HELP: empty-block?
|
|||
{ $description "Tests if the block has no child sections." } ;
|
||||
|
||||
HELP: if-nonempty
|
||||
{ $values { "block" block } { "quot" { $quotation "( block -- )" } } }
|
||||
{ $values { "block" block } { "quot" { $quotation ( block -- ) } } }
|
||||
{ $description "If the block has child sections, calls the quotation, otherwise does nothing." } ;
|
||||
|
||||
HELP: (<block)
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
USING: help.markup help.syntax ;
|
||||
IN: promises
|
||||
|
||||
HELP: promise
|
||||
{ $values { "quot" { $quotation "( -- X )" } } { "promise" "a promise object" } }
|
||||
HELP: <promise>
|
||||
{ $values { "quot" { $quotation ( -- x ) } } { "promise" "a promise object" } }
|
||||
{ $description "Creates a promise to return a value. When forced this quotation is called and the value returned. The value is memorised so that calling " { $link force } " again does not call the quotation again, instead the previous value is returned directly." } ;
|
||||
|
||||
HELP: force
|
||||
|
@ -12,7 +12,7 @@ HELP: force
|
|||
{ $description "Calls the quotation associated with the promise if it has not been called before, and returns the value. If the promise has been forced previously, returns the value from the previous call." } ;
|
||||
|
||||
HELP: LAZY:
|
||||
{ $syntax "LAZY: word ( stack -- effect ) definition... ;" }
|
||||
{ $syntax "LAZY: word ( stack -- effect ) definition... ;" }
|
||||
{ $values { "word" "a new word to define" } { "definition" "a word definition" } }
|
||||
{ $description "Creates a lazy word in the current vocabulary. When executed the word will return a " { $link promise } " that when forced, executes the word definition. Any values on the stack that are required by the word definition are captured along with the promise." }
|
||||
{ $examples
|
||||
|
|
|
@ -236,7 +236,7 @@ HELP: re-replace
|
|||
} ;
|
||||
|
||||
HELP: re-replace-with
|
||||
{ $values { "string" string } { "regexp" regexp } { "quot" { $quotation "( slice -- replacement )" } } { "result" string } }
|
||||
{ $values { "string" string } { "regexp" regexp } { "quot" { $quotation ( slice -- replacement ) } } { "result" string } }
|
||||
{ $description "Replaces substrings which match the input regexp with the result of calling " { $snippet "quot" } " on each matching slice. The boundaries of the substring are chosen by the strategy used by " { $link all-matching-slices } "." }
|
||||
{ $examples
|
||||
{ $example
|
||||
|
|
|
@ -2,31 +2,31 @@ USING: help.syntax help.markup kernel sequences ;
|
|||
IN: sequences.deep
|
||||
|
||||
HELP: deep-each
|
||||
{ $values { "obj" object } { "quot" { $quotation "( ... elt -- ... )" } } }
|
||||
{ $values { "obj" object } { "quot" { $quotation ( ... elt -- ... ) } } }
|
||||
{ $description "Execute a quotation on each nested element of an object and its children, in preorder." }
|
||||
{ $see-also each } ;
|
||||
|
||||
HELP: deep-map
|
||||
{ $values { "obj" object } { "quot" { $quotation "( ... elt -- ... elt' )" } } { "newobj" "the mapped object" } }
|
||||
{ $values { "obj" object } { "quot" { $quotation ( ... elt -- ... elt' ) } } { "newobj" "the mapped object" } }
|
||||
{ $description "Execute a quotation on each nested element of an object and its children, in preorder. That is, the result of the execution of the quotation on the outer is used to map the inner elements." }
|
||||
{ $see-also map } ;
|
||||
|
||||
HELP: deep-filter-as
|
||||
{ $values { "obj" object } { "quot" { $quotation "( ... elt -- ... ? )" } } { "exemplar" sequence } { "seq" sequence } }
|
||||
{ $values { "obj" object } { "quot" { $quotation ( ... elt -- ... ? ) } } { "exemplar" sequence } { "seq" sequence } }
|
||||
{ $description "Creates a sequence (of the same type as " { $snippet "exemplar" } ") of sub-nodes in the object which satisfy the given quotation, in preorder. This includes the object itself, if it passes the quotation." } ;
|
||||
|
||||
HELP: deep-filter
|
||||
{ $values { "obj" object } { "quot" { $quotation "( ... elt -- ... ? )" } } { "seq" sequence } }
|
||||
{ $values { "obj" object } { "quot" { $quotation ( ... elt -- ... ? ) } } { "seq" sequence } }
|
||||
{ $description "Creates a sequence of sub-nodes in the object which satisfy the given quotation, in preorder. This includes the object itself, if it passes the quotation." }
|
||||
{ $see-also filter } ;
|
||||
|
||||
HELP: deep-find
|
||||
{ $values { "obj" object } { "quot" { $quotation "( ... elt -- ... ? )" } } { "elt" "an element" } }
|
||||
{ $values { "obj" object } { "quot" { $quotation ( ... elt -- ... ? ) } } { "elt" "an element" } }
|
||||
{ $description "Gets the first sub-node of the object, in preorder, which satisfies the quotation. If nothing satisfies it, it returns " { $link f } "." }
|
||||
{ $see-also find } ;
|
||||
|
||||
HELP: deep-any?
|
||||
{ $values { "obj" object } { "quot" { $quotation "( ... elt -- ... ? )" } } { "?" "a boolean" } }
|
||||
{ $values { "obj" object } { "quot" { $quotation ( ... elt -- ... ? ) } } { "?" "a boolean" } }
|
||||
{ $description "Tests whether the given object or any subnode satisfies the given quotation." }
|
||||
{ $see-also any? } ;
|
||||
|
||||
|
@ -39,7 +39,7 @@ HELP: flatten
|
|||
{ $description "Creates a sequence of all of the leaf nodes (non-sequence nodes, but including strings and numbers) in the object." } ;
|
||||
|
||||
HELP: deep-map!
|
||||
{ $values { "obj" object } { "quot" { $quotation "( ... elt -- ... elt' )" } } }
|
||||
{ $values { "obj" object } { "quot" { $quotation ( ... elt -- ... elt' ) } } }
|
||||
{ $description "Modifies each sub-node of an object in place, in preorder, and returns that object." }
|
||||
{ $see-also map! } ;
|
||||
|
||||
|
|
|
@ -83,47 +83,47 @@ HELP: nappend-as
|
|||
{ nappend nappend-as } related-words
|
||||
|
||||
HELP: neach
|
||||
{ $values { "seq..." { $snippet "n" } " sequences on the datastack" } { "quot" { $quotation "( element... -- )" } } { "n" integer } }
|
||||
{ $values { "seq..." { $snippet "n" } " sequences on the datastack" } { "quot" { $quotation ( element... -- ) } } { "n" integer } }
|
||||
{ $description "A generalization of " { $link each } ", " { $link 2each } ", and " { $link 3each } " that can iterate over any number of sequences in parallel." } ;
|
||||
|
||||
HELP: nmap
|
||||
{ $values { "seq..." { $snippet "n" } " sequences on the datastack" } { "quot" { $quotation "( element... -- result )" } } { "n" integer } { "result" "a sequence of the same type as the first " { $snippet "seq" } } }
|
||||
{ $values { "seq..." { $snippet "n" } " sequences on the datastack" } { "quot" { $quotation ( element... -- result ) } } { "n" integer } { "result" "a sequence of the same type as the first " { $snippet "seq" } } }
|
||||
{ $description "A generalization of " { $link map } ", " { $link 2map } ", and " { $link 3map } " that can map over any number of sequences in parallel." } ;
|
||||
|
||||
HELP: nmap-as
|
||||
{ $values { "seq..." { $snippet "n" } " sequences on the datastack" } { "quot" { $quotation "( element... -- result )" } } { "exemplar" sequence } { "n" integer } { "result" "a sequence of the same type as " { $snippet "exemplar" } } }
|
||||
{ $values { "seq..." { $snippet "n" } " sequences on the datastack" } { "quot" { $quotation ( element... -- result ) } } { "exemplar" sequence } { "n" integer } { "result" "a sequence of the same type as " { $snippet "exemplar" } } }
|
||||
{ $description "A generalization of " { $link map-as } ", " { $link 2map-as } ", and " { $link 3map-as } " that can map over any number of sequences in parallel." } ;
|
||||
|
||||
HELP: mnmap
|
||||
{ $values { "m*seq" { $snippet "m" } " sequences on the datastack" } { "quot" { $quotation "( m*element -- result*n )" } } { "m" integer } { "n" integer } { "result*n" { $snippet "n" } " sequences of the same type as the first " { $snippet "seq" } } }
|
||||
{ $values { "m*seq" { $snippet "m" } " sequences on the datastack" } { "quot" { $quotation ( m*element -- result*n ) } } { "m" integer } { "n" integer } { "result*n" { $snippet "n" } " sequences of the same type as the first " { $snippet "seq" } } }
|
||||
{ $description "A generalization of " { $link map } ", " { $link 2map } ", and " { $link 3map } " that can map over any number of sequences in parallel and provide any number of output sequences." } ;
|
||||
|
||||
HELP: mnmap-as
|
||||
{ $values { "m*seq" { $snippet "m" } " sequences on the datastack" } { "quot" { $quotation "( m*element -- result*n )" } } { "n*exemplar" { $snippet "n" } " sequences on the datastack" } { "m" integer } { "n" integer } { "result*n" { $snippet "n" } " sequences on the datastack of the same types as the " { $snippet "exemplar" } "s" } }
|
||||
{ $values { "m*seq" { $snippet "m" } " sequences on the datastack" } { "quot" { $quotation ( m*element -- result*n ) } } { "n*exemplar" { $snippet "n" } " sequences on the datastack" } { "m" integer } { "n" integer } { "result*n" { $snippet "n" } " sequences on the datastack of the same types as the " { $snippet "exemplar" } "s" } }
|
||||
{ $description "A generalization of " { $link map-as } ", " { $link 2map-as } ", and " { $link 3map-as } " that can map over any number of sequences in parallel and provide any number of output sequences of distinct types." } ;
|
||||
|
||||
HELP: nproduce
|
||||
{ $values { "pred" { $quotation "( -- ? )" } } { "quot" { $quotation "( -- obj1 obj2 ... objn )" } } { "n" integer } { "seq..." { $snippet "n" } " arrays on the datastack" } }
|
||||
{ $values { "pred" { $quotation ( -- ? ) } } { "quot" { $quotation "( -- obj1 obj2 ... objn )" } } { "n" integer } { "seq..." { $snippet "n" } " arrays on the datastack" } }
|
||||
{ $description "A generalization of " { $link produce } " that generates " { $snippet "n" } " arrays in parallel by calling " { $snippet "quot" } " repeatedly until " { $snippet "pred" } " outputs false." } ;
|
||||
|
||||
HELP: nproduce-as
|
||||
{ $values { "pred" { $quotation "( -- ? )" } } { "quot" { $quotation "( -- obj1 obj2 ... objn )" } } { "exemplar..." { $snippet "n" } " sequences on the datastack" } { "n" integer } { "seq..." { $snippet "n" } " sequences on the datastack of the same types as the " { $snippet "exemplar" } "s" } }
|
||||
{ $values { "pred" { $quotation ( -- ? ) } } { "quot" { $quotation "( -- obj1 obj2 ... objn )" } } { "exemplar..." { $snippet "n" } " sequences on the datastack" } { "n" integer } { "seq..." { $snippet "n" } " sequences on the datastack of the same types as the " { $snippet "exemplar" } "s" } }
|
||||
{ $description "A generalization of " { $link produce-as } " that generates " { $snippet "n" } " sequences in parallel by calling " { $snippet "quot" } " repeatedly until " { $snippet "pred" } " outputs false." } ;
|
||||
|
||||
HELP: nmap-reduce
|
||||
{ $values { "map-quot" { $quotation "( element... -- intermediate )" } } { "reduce-quot" { $quotation "( prev intermediate -- next )" } } { "n" integer } }
|
||||
{ $values { "map-quot" { $quotation ( element... -- intermediate ) } } { "reduce-quot" { $quotation ( prev intermediate -- next ) } } { "n" integer } }
|
||||
{ $description "A generalization of " { $link map-reduce } " that can be applied to any number of sequences." } ;
|
||||
|
||||
HELP: nall?
|
||||
{ $values { "seqs..." { $snippet "n" } " sequences on the datastack" } { "quot" { $quotation "( element... - ? )" } } { "n" integer } { "?" boolean } }
|
||||
{ $values { "seqs..." { $snippet "n" } " sequences on the datastack" } { "quot" { $quotation ( element... -- ? ) } } { "n" integer } { "?" boolean } }
|
||||
{ $description "A generalization of " { $link all? } " that can be applied to any number of sequences." } ;
|
||||
|
||||
HELP: nfind
|
||||
{ $values { "seqs..." { $snippet "n" } " sequences on the datastack" } { "quot" { $quotation "( element... - ? )" } } { "n" integer } { "i" integer } { "elts..." { $snippet "n" } " elements on the datastack" } }
|
||||
{ $values { "seqs..." { $snippet "n" } " sequences on the datastack" } { "quot" { $quotation ( element... -- ? ) } } { "n" integer } { "i" integer } { "elts..." { $snippet "n" } " elements on the datastack" } }
|
||||
{ $description "A generalization of " { $link find } " that can be applied to any number of sequences." } ;
|
||||
|
||||
HELP: nany?
|
||||
{ $values { "seqs..." { $snippet "n" } " sequences on the datastack" } { "quot" { $quotation "( element... - ? )" } } { "n" integer } { "?" boolean } }
|
||||
{ $values { "seqs..." { $snippet "n" } " sequences on the datastack" } { "quot" { $quotation ( element... -- ? ) } } { "n" integer } { "?" boolean } }
|
||||
{ $description "A generalization of " { $link any? } " that can be applied to any number of sequences." } ;
|
||||
|
||||
ARTICLE: "sequences.generalizations" "Generalized sequence words"
|
||||
|
|
|
@ -40,20 +40,20 @@ HELP: <product-sequence>
|
|||
{ product-sequence <product-sequence> } related-words
|
||||
|
||||
HELP: product-map
|
||||
{ $values { "sequences" sequence } { "quot" { $quotation "( ... seq -- ... value )" } } { "sequence" sequence } }
|
||||
{ $values { "sequences" sequence } { "quot" { $quotation ( ... seq -- ... value ) } } { "sequence" sequence } }
|
||||
{ $description "Calls " { $snippet "quot" } " for every element of the cartesian product of " { $snippet "sequences" } " and collects the results from " { $snippet "quot" } " into an output sequence." }
|
||||
{ $notes { $snippet "[ ... ] product-map" } " is equivalent to, but more efficient than, " { $snippet "<product-sequence> [ ... ] map" } "." } ;
|
||||
|
||||
HELP: product-map-as
|
||||
{ $values { "sequences" sequence } { "quot" { $quotation "( ... seq -- ... value )" } } { "exemplar" sequence } { "sequence" sequence } }
|
||||
{ $values { "sequences" sequence } { "quot" { $quotation ( ... seq -- ... value ) } } { "exemplar" sequence } { "sequence" sequence } }
|
||||
{ $description "Calls " { $snippet "quot" } " for every element of the cartesian product of " { $snippet "sequences" } " and collects the results from " { $snippet "quot" } " into an output sequence the same type as the " { $snippet "exemplar" } " sequence." } ;
|
||||
|
||||
HELP: product-map>assoc
|
||||
{ $values { "sequences" sequence } { "quot" { $quotation "( ... seq -- ... key value )" } } { "exemplar" assoc } { "assoc" assoc } }
|
||||
{ $values { "sequences" sequence } { "quot" { $quotation ( ... seq -- ... key value ) } } { "exemplar" assoc } { "assoc" assoc } }
|
||||
{ $description "Calls " { $snippet "quot" } " for every element of the cartesian product of " { $snippet "sequences" } " and collects the results from " { $snippet "quot" } " into an output assoc." } ;
|
||||
|
||||
HELP: product-each
|
||||
{ $values { "sequences" sequence } { "quot" { $quotation "( ... seq -- ... )" } } }
|
||||
{ $values { "sequences" sequence } { "quot" { $quotation ( ... seq -- ... ) } } }
|
||||
{ $description "Calls " { $snippet "quot" } " for every element of the cartesian product of " { $snippet "sequences" } "." }
|
||||
{ $notes { $snippet "[ ... ] product-each" } " is equivalent to, but more efficient than, " { $snippet "<product-sequence> [ ... ] each" } "." } ;
|
||||
|
||||
|
|
|
@ -5,70 +5,70 @@ IN: sequences.unrolled
|
|||
|
||||
HELP: unrolled-collect
|
||||
{ $values
|
||||
{ "n" integer } { "quot" { $quotation "( n -- value )" } } { "into" sequence }
|
||||
{ "n" integer } { "quot" { $quotation ( n -- value ) } } { "into" sequence }
|
||||
}
|
||||
{ $description "Unrolled version of " { $link collect } ". " { $snippet "n" } " must be a compile-time constant." } ;
|
||||
|
||||
HELP: unrolled-each
|
||||
{ $values
|
||||
{ "seq" sequence } { "len" integer } { "quot" { $quotation "( x -- )" } }
|
||||
{ "seq" sequence } { "len" integer } { "quot" { $quotation ( x -- ) } }
|
||||
}
|
||||
{ $description "Unrolled version of " { $link each } " that iterates over the first " { $snippet "len" } " elements of " { $snippet "seq" } ". " { $snippet "len" } " must be a compile-time constant. If " { $snippet "seq" } " has fewer than " { $snippet "len" } " elements, raises an " { $link unrolled-bounds-error } "." } ;
|
||||
|
||||
HELP: unrolled-2each
|
||||
{ $values
|
||||
{ "xseq" sequence } { "yseq" sequence } { "len" integer } { "quot" { $quotation "( x y -- )" } }
|
||||
{ "xseq" sequence } { "yseq" sequence } { "len" integer } { "quot" { $quotation ( x y -- ) } }
|
||||
}
|
||||
{ $description "Unrolled version of " { $link 2each } " that iterates over the first " { $snippet "len" } " elements of " { $snippet "xseq" } " and " { $snippet "yseq" } ". " { $snippet "len" } " must be a compile-time constant. If " { $snippet "seq" } " has fewer than " { $snippet "len" } " elements, raises an " { $link unrolled-bounds-error } "." } ;
|
||||
|
||||
HELP: unrolled-each-index
|
||||
{ $values
|
||||
{ "seq" sequence } { "len" integer } { "quot" { $quotation "( x i -- )" } }
|
||||
{ "seq" sequence } { "len" integer } { "quot" { $quotation ( x i -- ) } }
|
||||
}
|
||||
{ $description "Unrolled version of " { $link each-index } " that iterates over the first " { $snippet "len" } " elements of " { $snippet "seq" } ". " { $snippet "len" } " must be a compile-time constant. If " { $snippet "seq" } " has fewer than " { $snippet "len" } " elements, raises an " { $link unrolled-bounds-error } "." } ;
|
||||
|
||||
HELP: unrolled-each-integer
|
||||
{ $values
|
||||
{ "n" integer } { "quot" { $quotation "( i -- )" } }
|
||||
{ "n" integer } { "quot" { $quotation ( i -- ) } }
|
||||
}
|
||||
{ $description "Unrolled version of " { $link each-integer } ". " { $snippet "n" } " must be a compile-time constant." } ;
|
||||
|
||||
HELP: unrolled-map
|
||||
{ $values
|
||||
{ "seq" sequence } { "len" integer } { "quot" { $quotation "( x -- newx )" } }
|
||||
{ "seq" sequence } { "len" integer } { "quot" { $quotation ( x -- newx ) } }
|
||||
{ "newseq" sequence }
|
||||
}
|
||||
{ $description "Unrolled version of " { $link map } " that maps over the first " { $snippet "len" } " elements of " { $snippet "seq" } ". " { $snippet "len" } " must be a compile-time constant. If " { $snippet "seq" } " has fewer than " { $snippet "len" } " elements, raises an " { $link unrolled-bounds-error } "." } ;
|
||||
|
||||
HELP: unrolled-map-as
|
||||
{ $values
|
||||
{ "seq" sequence } { "len" integer } { "quot" { $quotation "( x -- newx )" } } { "exemplar" sequence }
|
||||
{ "seq" sequence } { "len" integer } { "quot" { $quotation ( x -- newx ) } } { "exemplar" sequence }
|
||||
{ "newseq" sequence }
|
||||
}
|
||||
{ $description "Unrolled version of " { $link map-as } " that maps over the first " { $snippet "len" } " elements of " { $snippet "seq" } ". " { $snippet "len" } " must be a compile-time constant. If " { $snippet "seq" } " has fewer than " { $snippet "len" } " elements, raises an " { $link unrolled-bounds-error } "." } ;
|
||||
|
||||
HELP: unrolled-2map
|
||||
{ $values
|
||||
{ "xseq" sequence } { "yseq" sequence } { "len" integer } { "quot" { $quotation "( x y -- newx )" } } { "newseq" sequence }
|
||||
{ "xseq" sequence } { "yseq" sequence } { "len" integer } { "quot" { $quotation ( x y -- newx ) } } { "newseq" sequence }
|
||||
}
|
||||
{ $description "Unrolled version of " { $link 2map } " that iterates over the first " { $snippet "len" } " elements of " { $snippet "xseq" } " and " { $snippet "yseq" } ". " { $snippet "len" } " must be a compile-time constant. If " { $snippet "seq" } " has fewer than " { $snippet "len" } " elements, raises an " { $link unrolled-bounds-error } "." } ;
|
||||
|
||||
HELP: unrolled-2map-as
|
||||
{ $values
|
||||
{ "xseq" sequence } { "yseq" sequence } { "len" integer } { "quot" { $quotation "( x y -- newx )" } } { "exemplar" sequence } { "newseq" sequence }
|
||||
{ "xseq" sequence } { "yseq" sequence } { "len" integer } { "quot" { $quotation ( x y -- newx ) } } { "exemplar" sequence } { "newseq" sequence }
|
||||
}
|
||||
{ $description "Unrolled version of " { $link 2map-as } " that iterates over the first " { $snippet "len" } " elements of " { $snippet "xseq" } " and " { $snippet "yseq" } ". " { $snippet "len" } " must be a compile-time constant. If " { $snippet "seq" } " has fewer than " { $snippet "len" } " elements, raises an " { $link unrolled-bounds-error } "." } ;
|
||||
|
||||
HELP: unrolled-map-index
|
||||
{ $values
|
||||
{ "seq" sequence } { "len" integer } { "quot" { $quotation "( x i -- newx )" } }
|
||||
{ "seq" sequence } { "len" integer } { "quot" { $quotation ( x i -- newx ) } }
|
||||
{ "newseq" sequence }
|
||||
}
|
||||
{ $description "Unrolled version of " { $link map-index } " that maps over the first " { $snippet "len" } " elements of " { $snippet "seq" } ". " { $snippet "len" } " must be a compile-time constant. If " { $snippet "seq" } " has fewer than " { $snippet "len" } " elements, raises an " { $link unrolled-bounds-error } "." } ;
|
||||
|
||||
HELP: unrolled-map-integers
|
||||
{ $values
|
||||
{ "n" integer } { "quot" { $quotation "( n -- value )" } } { "exemplar" sequence } { "newseq" sequence }
|
||||
{ "n" integer } { "quot" { $quotation ( n -- value ) } } { "exemplar" sequence } { "newseq" sequence }
|
||||
}
|
||||
{ $description "Unrolled version of " { $link map-integers } ". " { $snippet "n" } " must be a compile-time constant." } ;
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ $nl
|
|||
} ;
|
||||
|
||||
HELP: spawn-server
|
||||
{ $values { "quot" { $quotation "( -- ? )" } } { "name" string } { "thread" thread } }
|
||||
{ $values { "quot" { $quotation ( -- ? ) } } { "name" string } { "thread" thread } }
|
||||
{ $description "Convenience wrapper around " { $link spawn } " which repeatedly calls the quotation in a new thread until it outputs " { $link f } "." }
|
||||
{ $examples
|
||||
"A thread that runs forever:"
|
||||
|
@ -198,5 +198,5 @@ HELP: tset
|
|||
{ $description "Sets the value of a thread-local variable." } ;
|
||||
|
||||
HELP: tchange
|
||||
{ $values { "key" object } { "quot" { $quotation "( ..a value -- ..b newvalue )" } } }
|
||||
{ $values { "key" object } { "quot" { $quotation ( ..a value -- ..b newvalue ) } } }
|
||||
{ $description "Applies the quotation to the current value of a thread-local variable, storing the result back to the same variable." } ;
|
||||
|
|
|
@ -25,7 +25,7 @@ $nl
|
|||
ABOUT: "tools.annotations"
|
||||
|
||||
HELP: annotate
|
||||
{ $values { "word" "a word" } { "quot" { $quotation "( old-def -- new-def )" } } }
|
||||
{ $values { "word" "a word" } { "quot" { $quotation ( old-def -- new-def ) } } }
|
||||
{ $description "Changes a word definition to the result of applying a quotation to the old definition." }
|
||||
{ $notes "This word is used to implement " { $link watch } "." } ;
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ HELP: must-fail
|
|||
{ $notes "This word is used to test boundary conditions and fail-fast behavior." } ;
|
||||
|
||||
HELP: must-fail-with
|
||||
{ $values { "quot" "a quotation run with an empty stack" } { "pred" { $quotation "( error -- ? )" } } }
|
||||
{ $values { "quot" "a quotation run with an empty stack" } { "pred" { $quotation ( error -- ? ) } } }
|
||||
{ $description "Runs a quotation with an empty stack, expecting it to throw an error which must satisfy " { $snippet "pred" } ". If the quotation does not throw an error, or if the error does not match the predicate, the unit test fails." }
|
||||
{ $notes "This word is used to test error handling code, ensuring that errors thrown by code contain the relevant debugging information." } ;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ HELP: breakpoint
|
|||
} ;
|
||||
|
||||
HELP: breakpoint-if
|
||||
{ $values { "word" word } { "quot" { $quotation "( -- ? )" } } }
|
||||
{ $values { "word" word } { "quot" { $quotation ( -- ? ) } } }
|
||||
{ $description "Annotates a word definition to enter the single stepper if the quotation yields true. The quotation has access to the datastack as it exists just before " { $snippet "word" } " is called." }
|
||||
{ $examples
|
||||
"Break if the input to sq is 3:"
|
||||
|
|
|
@ -12,19 +12,19 @@ $nl
|
|||
"A button can optionally display a message in the window's status bar whenever the mouse cursor hovers over the button. To enable this behavior, just set a string to the button's " { $snippet "tooltip" } " slot." } ;
|
||||
|
||||
HELP: <button>
|
||||
{ $values { "label" gadget } { "quot" { $quotation "( button -- )" } } { "button" "a new " { $link button } } }
|
||||
{ $values { "label" gadget } { "quot" { $quotation ( button -- ) } } { "button" "a new " { $link button } } }
|
||||
{ $description "Creates a new " { $link button } " which calls the quotation when clicked. The given gadget becomes the button's only child." } ;
|
||||
|
||||
HELP: <roll-button>
|
||||
{ $values { "label" "a label specifier" } { "quot" { $quotation "( button -- )" } } { "button" button } }
|
||||
{ $values { "label" "a label specifier" } { "quot" { $quotation ( button -- ) } } { "button" button } }
|
||||
{ $description "Creates a new " { $link button } " which is displayed with a solid border when it is under the mouse, informing the user that the gadget is clickable." } ;
|
||||
|
||||
HELP: <border-button>
|
||||
{ $values { "label" "a label specifier" } { "quot" { $quotation "( button -- )" } } { "button" button } }
|
||||
{ $values { "label" "a label specifier" } { "quot" { $quotation ( button -- ) } } { "button" button } }
|
||||
{ $description "Creates a new " { $link button } " with a border which is always visible. The button appearance changes in response to mouse gestures using a " { $link button-pen } "." } ;
|
||||
|
||||
HELP: <repeat-button>
|
||||
{ $values { "label" object } { "quot" { $quotation "( button -- )" } } { "button" repeat-button } }
|
||||
{ $values { "label" object } { "quot" { $quotation ( button -- ) } } { "button" repeat-button } }
|
||||
{ $description "Creates a new " { $link button } " derived from a " { $link <border-button> } " which calls the quotation every 100 milliseconds as long as the mouse button is held down." } ;
|
||||
|
||||
HELP: button-pen
|
||||
|
|
|
@ -32,7 +32,7 @@ HELP: editor-mark
|
|||
{ $description "Outputs the current mark location as a line/column number pair." } ;
|
||||
|
||||
HELP: change-caret
|
||||
{ $values { "editor" editor } { "quot" { $quotation "( loc document -- newloc )" } } }
|
||||
{ $values { "editor" editor } { "quot" { $quotation ( loc document -- newloc ) } } }
|
||||
{ $description "Applies a quotation to the current caret location and moves the caret to the location output by the quotation." } ;
|
||||
|
||||
{ change-caret change-caret&mark mark>caret } related-words
|
||||
|
@ -42,7 +42,7 @@ HELP: mark>caret
|
|||
{ $description "Moves the mark to the caret location, effectively deselecting any selected text." } ;
|
||||
|
||||
HELP: change-caret&mark
|
||||
{ $values { "editor" editor } { "quot" { $quotation "( loc document -- newloc )" } } }
|
||||
{ $values { "editor" editor } { "quot" { $quotation ( loc document -- newloc ) } } }
|
||||
{ $description "Applies a quotation to the current caret location and moves the caret and the mark to the location output by the quotation." } ;
|
||||
|
||||
HELP: point>loc
|
||||
|
|
|
@ -45,7 +45,7 @@ HELP: max-dims
|
|||
{ pref-dims max-dims sum-dims } related-words
|
||||
|
||||
HELP: each-child
|
||||
{ $values { "gadget" gadget } { "quot" { $quotation "( child -- )" } } }
|
||||
{ $values { "gadget" gadget } { "quot" { $quotation ( child -- ) } } }
|
||||
{ $description "Applies the quotation to each child of the gadget." } ;
|
||||
|
||||
HELP: gadget-selection?
|
||||
|
@ -147,11 +147,11 @@ HELP: parents
|
|||
{ $description "Outputs a sequence of all parents of the gadget, with the first element being the gadget itself." } ;
|
||||
|
||||
HELP: each-parent
|
||||
{ $values { "gadget" gadget } { "quot" { $quotation "( gadget -- ? )" } } { "?" "a boolean" } }
|
||||
{ $values { "gadget" gadget } { "quot" { $quotation ( gadget -- ? ) } } { "?" "a boolean" } }
|
||||
{ $description "Applies the quotation to every parent of the gadget, starting from the gadget itself, stopping if the quotation yields " { $link f } ". Outputs " { $link t } " if the iteration completed, and outputs " { $link f } " if it was stopped prematurely." } ;
|
||||
|
||||
HELP: find-parent
|
||||
{ $values { "gadget" gadget } { "quot" { $quotation "( gadget -- ? )" } } { "parent" gadget } }
|
||||
{ $values { "gadget" gadget } { "quot" { $quotation ( gadget -- ? ) } } { "parent" gadget } }
|
||||
{ $description "Outputs the first parent of the gadget, starting from the gadget itself, for which the quotation outputs a true value, or " { $link f } " if the quotation outputs " { $link f } " for every parent." } ;
|
||||
|
||||
HELP: screen-loc
|
||||
|
|
|
@ -3,7 +3,7 @@ kernel ;
|
|||
IN: ui.gadgets.menus
|
||||
|
||||
HELP: <commands-menu>
|
||||
{ $values { "target" object } { "hook" { $quotation "( button -- )" } } { "commands" "a sequence of commands" } { "menu" "a new " { $link gadget } } }
|
||||
{ $values { "target" object } { "hook" { $quotation ( button -- ) } } { "commands" "a sequence of commands" } { "menu" "a new " { $link gadget } } }
|
||||
{ $description "Creates a popup menu of commands which are to be invoked on " { $snippet "target" } ". The " { $snippet "hook" } " quotation is run before a command is invoked." } ;
|
||||
|
||||
HELP: show-menu
|
||||
|
|
|
@ -35,7 +35,7 @@ HELP: make-pane
|
|||
{ $description "Calls the quotation in a new scope where " { $link output-stream } " is rebound to a " { $link pane-stream } " writing to a new pane. The output area of the new pane is output on the stack after the quotation returns. The pane itself is not output." } ;
|
||||
|
||||
HELP: <pane-control>
|
||||
{ $values { "model" model } { "quot" { $quotation "( value -- )" } } { "pane" "a new " { $link pane } } }
|
||||
{ $values { "model" model } { "quot" { $quotation ( value -- ) } } { "pane" "a new " { $link pane } } }
|
||||
{ $description "Creates a new control delegating to a " { $link pane } ". When the value of the model changes, the value is pushed on the stack and the quotation is called using " { $link with-pane } "." } ;
|
||||
|
||||
HELP: pane-stream
|
||||
|
|
|
@ -11,7 +11,7 @@ $nl
|
|||
"Presentations have two slots:"
|
||||
{ $list
|
||||
{ { $snippet "object" } " - the object being presented." }
|
||||
{ { $snippet "hook" } " - " { $quotation "( presentation -- )" } ". The default value is " { $snippet "[ drop ]" } "." }
|
||||
{ { $snippet "hook" } " - " { $quotation ( presentation -- ) } ". The default value is " { $snippet "[ drop ]" } "." }
|
||||
} } ;
|
||||
|
||||
HELP: invoke-presentation
|
||||
|
|
|
@ -22,10 +22,10 @@ HELP: operation
|
|||
$nl
|
||||
"Operations have the following slots:"
|
||||
{ $list
|
||||
{ { $snippet "predicate" } " - " { $quotation "( obj -- ? )" } }
|
||||
{ { $snippet "predicate" } " - " { $quotation ( obj -- ? ) } }
|
||||
{ { $snippet "command" } " - a " { $link word } }
|
||||
{ { $snippet "translator" } " - " { $quotation "( obj -- newobj )" } ", or " { $link f } }
|
||||
{ { $snippet "hook" } " - " { $quotation "( obj -- newobj )" } ", or " { $link f } }
|
||||
{ { $snippet "translator" } " - " { $quotation ( obj -- newobj ) } ", or " { $link f } }
|
||||
{ { $snippet "hook" } " - " { $quotation ( obj -- newobj ) } ", or " { $link f } }
|
||||
{ { $snippet "listener?" } " - a boolean" }
|
||||
} } ;
|
||||
|
||||
|
@ -49,7 +49,7 @@ HELP: secondary-operation
|
|||
{ $description "Outputs the operation which should be invoked when a " { $snippet "RET" } " is pressed while a presentation of " { $snippet "obj" } " is selected in a list." } ;
|
||||
|
||||
HELP: define-operation
|
||||
{ $values { "pred" { $quotation "( obj -- ? )" } } { "command" word } { "flags" hashtable } }
|
||||
{ $values { "pred" { $quotation ( obj -- ? ) } } { "command" word } { "flags" hashtable } }
|
||||
{ $description "Defines an operation on objects matching the predicate. The hashtable can contain the following keys:"
|
||||
{ $list
|
||||
{ { $link +listener+ } " - if set to a true value, the operation will run in the listener" }
|
||||
|
@ -61,7 +61,7 @@ HELP: define-operation
|
|||
} ;
|
||||
|
||||
HELP: define-operation-map
|
||||
{ $values { "class" "a class word" } { "group" string } { "blurb" { $maybe string } } { "object" object } { "translator" { $quotation "( obj -- newobj )" } ", or " { $link f } } }
|
||||
{ $values { "class" "a class word" } { "group" string } { "blurb" { $maybe string } } { "object" object } { "translator" { $quotation ( obj -- newobj ) } ", or " { $link f } } }
|
||||
{ $description "Defines a command map named " { $snippet "group" } " on " { $snippet "class" } " consisting of operations applicable to " { $snippet "object" } ". The translator quotation is applied to the target gadget, and the result of the translator is passed to the operation." } ;
|
||||
|
||||
HELP: $operations
|
||||
|
|
|
@ -3,7 +3,7 @@ continuations debugger ui ;
|
|||
IN: ui.tools.debugger
|
||||
|
||||
HELP: <debugger>
|
||||
{ $values { "error" "an error" } { "continuation" continuation } { "restarts" "a sequence of " { $link restart } " instances" } { "restart-hook" { $quotation "( debugger -- )" } } { "debugger" "a new " { $link debugger } } }
|
||||
{ $values { "error" "an error" } { "continuation" continuation } { "restarts" "a sequence of " { $link restart } " instances" } { "restart-hook" { $quotation ( debugger -- ) } } { "debugger" "a new " { $link debugger } } }
|
||||
{ $description
|
||||
"Creates a gadget displaying a description of the error, along with buttons to print the contents of the stacks in the listener, and a list of restarts."
|
||||
} ;
|
||||
|
|
|
@ -42,7 +42,7 @@ HELP: fullscreen?
|
|||
{ fullscreen? set-fullscreen } related-words
|
||||
|
||||
HELP: find-window
|
||||
{ $values { "quot" { $quotation "( world -- ? )" } } { "world" { $maybe world } } }
|
||||
{ $values { "quot" { $quotation ( world -- ? ) } } { "world" { $maybe world } } }
|
||||
{ $description "Finds a native window such that the gadget passed to " { $link open-window } " satisfies the quotation, outputting " { $link f } " if no such gadget could be found. The front-most native window is checked first." } ;
|
||||
|
||||
HELP: register-window
|
||||
|
@ -74,7 +74,7 @@ HELP: raise-window
|
|||
{ $description "Makes the native window containing the given gadget the front-most window." } ;
|
||||
|
||||
HELP: with-ui
|
||||
{ $values { "quot" { $quotation "( -- )" } } }
|
||||
{ $values { "quot" { $quotation ( -- ) } } }
|
||||
{ $description "Calls the quotation, starting the UI if necessary. If starting the UI is necessary, this word does not return and the UI will start after the quotation returns." }
|
||||
{ $notes "This word should be used in the " { $link POSTPONE: MAIN: } " word of an application that uses the UI in order for the vocabulary to work when run from either the UI listener (" { $snippet "\"my-app\" run" } ") and the command line (" { $snippet "./factor -run=my-app" } ")." }
|
||||
{ $examples "The " { $vocab-link "hello-ui" } " vocabulary implements a simple UI application which uses this word." } ;
|
||||
|
|
|
@ -4,14 +4,14 @@ IN: unix.signals
|
|||
|
||||
HELP: add-signal-handler
|
||||
{ $values
|
||||
{ "handler" { $quotation "( -- )" } } { "sig" "a signal number" }
|
||||
{ "handler" { $quotation ( -- ) } } { "sig" "a signal number" }
|
||||
}
|
||||
{ $description "Adds a signal handler for " { $snippet "sig" } ". If " { $snippet "sig" } " is raised, the signal handler will be run in a freshly-spawned Factor thread concurrently with any already established signal handlers for " { $snippet "sig" } ". Signal constants are available in the " { $vocab-link "unix.ffi" } " vocabulary." }
|
||||
{ $notes "Only certain signals can be handled. See " { $link "unix.signals:allowed-signals" } " for more information. The handler quotation will be run in its own freshly-spawned thread." } ;
|
||||
|
||||
HELP: remove-signal-handler
|
||||
{ $values
|
||||
{ "handler" { $quotation "( -- )" } } { "sig" "a signal handler" }
|
||||
{ "handler" { $quotation ( -- ) } } { "sig" "a signal handler" }
|
||||
}
|
||||
{ $description "Removes a signal handler for " { $snippet "sig" } ". " { $snippet "handler" } " must be the same quotation object that was passed to " { $link add-signal-handler } ". Signal constants are available in the " { $vocab-link "unix.ffi" } " vocabulary." } ;
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ HELP: new-assoc
|
|||
{ $contract "Creates a new assoc from an " { $snippet "exemplar" } " which can hold " { $snippet "capacity" } " entries before growing." } ;
|
||||
|
||||
HELP: assoc-find
|
||||
{ $values { "assoc" assoc } { "quot" { $quotation "( ... key value -- ... ? )" } } { "key" "the successful key, or f" } { "value" "the successful value, or f" } { "?" boolean } }
|
||||
{ $values { "assoc" assoc } { "quot" { $quotation ( ... key value -- ... ? ) } } { "key" "the successful key, or f" } { "value" "the successful value, or f" } { "?" boolean } }
|
||||
{ $description "Applies a predicate quotation to each entry in the assoc. Returns the key and value that the quotation succeeds on, or " { $link f } " for both if the quotation fails. It also returns a boolean describing whether there was anything found; this can be used to distinguish between a key and a value equal to " { $link f } ", or nothing being found." } ;
|
||||
|
||||
HELP: clear-assoc
|
||||
|
@ -257,7 +257,7 @@ HELP: ?of
|
|||
{ $description "Looks up the value associated with a key. If the key was not present, an error can be thrown without extra stack shuffling. This word handles assocs that store " { $link f } "." } ;
|
||||
|
||||
HELP: assoc-each
|
||||
{ $values { "assoc" assoc } { "quot" { $quotation "( ... key value -- ... )" } } }
|
||||
{ $values { "assoc" assoc } { "quot" { $quotation ( ... key value -- ... ) } } }
|
||||
{ $description "Applies a quotation to each entry in the assoc." }
|
||||
{ $examples
|
||||
{ $example
|
||||
|
@ -269,7 +269,7 @@ HELP: assoc-each
|
|||
} ;
|
||||
|
||||
HELP: assoc-map
|
||||
{ $values { "assoc" assoc } { "quot" { $quotation "( ... key value -- ... newkey newvalue )" } } { "newassoc" "a new assoc" } }
|
||||
{ $values { "assoc" assoc } { "quot" { $quotation ( ... key value -- ... newkey newvalue ) } } { "newassoc" "a new assoc" } }
|
||||
{ $description "Applies the quotation to each entry in the input assoc and collects the results in a new assoc of the same type as the input." }
|
||||
{ $examples
|
||||
{ $unchecked-example
|
||||
|
@ -284,15 +284,15 @@ HELP: assoc-map
|
|||
{ assoc-map assoc-map-as } related-words
|
||||
|
||||
HELP: assoc-filter
|
||||
{ $values { "assoc" assoc } { "quot" { $quotation "( ... key value -- ... ? )" } } { "subassoc" "a new assoc" } }
|
||||
{ $values { "assoc" assoc } { "quot" { $quotation ( ... 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." } ;
|
||||
|
||||
HELP: assoc-filter-as
|
||||
{ $values { "assoc" assoc } { "quot" { $quotation "( ... key value -- ... ? )" } } { "exemplar" assoc } { "subassoc" "a new assoc" } }
|
||||
{ $values { "assoc" assoc } { "quot" { $quotation ( ... key value -- ... ? ) } } { "exemplar" assoc } { "subassoc" "a new assoc" } }
|
||||
{ $description "Outputs an assoc of the same type as " { $snippet "exemplar" } " consisting of all entries for which the predicate quotation yields true." } ;
|
||||
|
||||
HELP: assoc-filter!
|
||||
{ $values { "assoc" assoc } { "quot" { $quotation "( ... key value -- ... ? )" } } }
|
||||
{ $values { "assoc" assoc } { "quot" { $quotation ( ... key value -- ... ? ) } } }
|
||||
{ $description "Removes all entries for which the predicate quotation yields true." }
|
||||
{ $side-effects "assoc" } ;
|
||||
|
||||
|
@ -306,11 +306,11 @@ HELP: assoc-partition
|
|||
{ $description "Calls a predicate quotation on each key of the input assoc. If the test yields true, the key/value pair is added to " { $snippet "true-assoc" } "; if false, it's added to " { $snippet "false-assoc" } "." } ;
|
||||
|
||||
HELP: assoc-any?
|
||||
{ $values { "assoc" assoc } { "quot" { $quotation "( ... key value -- ... ? )" } } { "?" boolean } }
|
||||
{ $values { "assoc" assoc } { "quot" { $quotation ( ... key value -- ... ? ) } } { "?" 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?
|
||||
{ $values { "assoc" assoc } { "quot" { $quotation "( ... key value -- ... ? )" } } { "?" boolean } }
|
||||
{ $values { "assoc" assoc } { "quot" { $quotation ( ... key value -- ... ? ) } } { "?" boolean } }
|
||||
{ $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: assoc-refine
|
||||
|
@ -405,25 +405,25 @@ HELP: substitute
|
|||
{ $description "Creates a new sequence where elements of " { $snippet "seq" } " which appear as keys in " { $snippet "assoc" } " are replaced by the corresponding values, and all other elements are unchanged." } ;
|
||||
|
||||
HELP: cache
|
||||
{ $values { "key" "a key" } { "assoc" assoc } { "quot" { $quotation "( ... key -- ... value )" } } { "value" "a previously-retained or freshly-computed value" } }
|
||||
{ $values { "key" "a key" } { "assoc" assoc } { "quot" { $quotation ( ... key -- ... value ) } } { "value" "a previously-retained or freshly-computed value" } }
|
||||
{ $description "If the key is present in the assoc, outputs the associated value, otherwise calls the quotation to produce a value and stores the key/value pair into the assoc. Returns a value either looked up or newly stored in the assoc." }
|
||||
{ $side-effects "assoc" } ;
|
||||
|
||||
HELP: 2cache
|
||||
{ $values { "key1" "a key" } { "key2" "a key" } { "assoc" assoc } { "quot" { $quotation "( ... key1 key2 -- ... value )" } } { "value" "a previously-retained or freshly-computed value" } }
|
||||
{ $values { "key1" "a key" } { "key2" "a key" } { "assoc" assoc } { "quot" { $quotation ( ... key1 key2 -- ... value ) } } { "value" "a previously-retained or freshly-computed value" } }
|
||||
{ $description "If a single key composed of the input keys is present in the assoc, outputs the associated value, otherwise calls the quotation to produce a value and stores the keys/value pair into the assoc. Returns the value stored in the assoc. Returns a value either looked up or newly stored in the assoc." }
|
||||
{ $side-effects "assoc" } ;
|
||||
|
||||
HELP: map>assoc
|
||||
{ $values { "seq" sequence } { "quot" { $quotation "( ... elt -- ... key value )" } } { "exemplar" assoc } { "assoc" "a new assoc" } }
|
||||
{ $values { "seq" sequence } { "quot" { $quotation ( ... elt -- ... key value ) } } { "exemplar" assoc } { "assoc" "a new assoc" } }
|
||||
{ $description "Applies the quotation to each element of the sequence, and collects the keys and values into a new assoc having the same type as " { $snippet "exemplar" } "." } ;
|
||||
|
||||
HELP: assoc>map
|
||||
{ $values { "assoc" assoc } { "quot" { $quotation "( ... key value -- ... elt )" } } { "exemplar" sequence } { "seq" "a new sequence" } }
|
||||
{ $values { "assoc" assoc } { "quot" { $quotation ( ... key value -- ... elt ) } } { "exemplar" sequence } { "seq" "a new sequence" } }
|
||||
{ $description "Applies the quotation to each entry of the assoc and collects the results into a new sequence of the same type as the exemplar." } ;
|
||||
|
||||
HELP: change-at
|
||||
{ $values { "key" object } { "assoc" assoc } { "quot" { $quotation "( ..a value -- ..b newvalue )" } } }
|
||||
{ $values { "key" object } { "assoc" assoc } { "quot" { $quotation ( ..a value -- ..b newvalue ) } } }
|
||||
{ $description "Applies the quotation to the value associated with " { $snippet "key" } ", storing the new value back in the assoc." }
|
||||
{ $side-effects "assoc" } ;
|
||||
|
||||
|
@ -459,7 +459,7 @@ HELP: assoc-combine
|
|||
|
||||
HELP: assoc-map-as
|
||||
{ $values
|
||||
{ "assoc" assoc } { "quot" { $quotation "( ... key value -- ... newkey newvalue )" } } { "exemplar" assoc }
|
||||
{ "assoc" assoc } { "quot" { $quotation ( ... key value -- ... newkey newvalue ) } } { "exemplar" assoc }
|
||||
{ "newassoc" assoc } }
|
||||
{ $description "Applies the quotation to each entry in the input assoc and collects the results in a new assoc of the same type as the exemplar." }
|
||||
{ $examples { $example "USING: prettyprint assocs hashtables math ;" " H{ { 1 2 } { 3 4 } } [ sq ] { } assoc-map-as ." "{ { 1 4 } { 3 16 } }" } } ;
|
||||
|
|
|
@ -18,7 +18,7 @@ ARTICLE: "predicates" "Predicate classes"
|
|||
ABOUT: "predicates"
|
||||
|
||||
HELP: define-predicate-class
|
||||
{ $values { "class" class } { "superclass" class } { "definition" { $quotation "( superclass -- ? )" } } }
|
||||
{ $values { "class" class } { "superclass" class } { "definition" { $quotation ( superclass -- ? ) } } }
|
||||
{ $description "Defines a predicate class. This is the run time equivalent of " { $link POSTPONE: PREDICATE: } "." }
|
||||
{ $notes "This word must be called from inside " { $link with-compilation-unit } "." }
|
||||
{ $side-effects "class" } ;
|
||||
|
|
|
@ -296,7 +296,7 @@ HELP: spread
|
|||
{ bi* tri* spread } related-words
|
||||
|
||||
HELP: to-fixed-point
|
||||
{ $values { "object" object } { "quot" { $quotation "( ... object(n) -- ... object(n+1) )" } } { "object(n)" object } }
|
||||
{ $values { "object" object } { "quot" { $quotation ( ... object(n) -- ... object(n+1) ) } } { "object(n)" object } }
|
||||
{ $description "Applies the quotation repeatedly with " { $snippet "object" } " as the initial input until the output of the quotation equals the input." }
|
||||
{ $examples
|
||||
{ $example
|
||||
|
@ -373,7 +373,7 @@ HELP: no-case
|
|||
{ $error-description "Thrown by " { $link case } " if the object at the top of the stack does not match any case, and no default case is given." } ;
|
||||
|
||||
HELP: recursive-hashcode
|
||||
{ $values { "n" integer } { "obj" object } { "quot" { $quotation "( n obj -- code )" } } { "code" integer } }
|
||||
{ $values { "n" integer } { "obj" object } { "quot" { $quotation ( n obj -- code ) } } { "code" integer } }
|
||||
{ $description "A combinator used to implement methods for the " { $link hashcode* } " generic word. If " { $snippet "n" } " is less than or equal to zero, outputs 0, otherwise calls the quotation." } ;
|
||||
|
||||
HELP: cond>quot
|
||||
|
@ -395,7 +395,7 @@ $nl
|
|||
} } ;
|
||||
|
||||
HELP: distribute-buckets
|
||||
{ $values { "alist" "an alist" } { "initial" object } { "quot" { $quotation "( obj -- assoc )" } } { "buckets" "a new array" } }
|
||||
{ $values { "alist" "an alist" } { "initial" object } { "quot" { $quotation ( obj -- assoc ) } } { "buckets" "a new array" } }
|
||||
{ $description "Sorts the entries of " { $snippet "assoc" } " into buckets, using the quotation to yield a set of keys for each entry. The hashcode of each key is computed, and the entry is placed in all corresponding buckets. Each bucket is initially cloned from " { $snippet "initial" } "; this should either be an empty vector or a one-element vector containing a pair." }
|
||||
{ $notes "This word is used in the implementation of " { $link hash-case-quot } " and " { $link standard-combination } "." } ;
|
||||
|
||||
|
|
|
@ -130,17 +130,17 @@ HELP: >continuation<
|
|||
{ $description "Takes a continuation apart into its constituents." } ;
|
||||
|
||||
HELP: ifcc
|
||||
{ $values { "capture" { $quotation "( continuation -- )" } } { "restore" quotation } }
|
||||
{ $values { "capture" { $quotation ( continuation -- ) } } { "restore" quotation } }
|
||||
{ $description "Reifies a continuation from the point immediately after which this word returns, and passes it to " { $snippet "capture" } ". When the continuation is restored, execution resumes and " { $snippet "restore" } " is called." } ;
|
||||
|
||||
{ callcc0 continue callcc1 continue-with ifcc } related-words
|
||||
|
||||
HELP: callcc0
|
||||
{ $values { "quot" { $quotation "( continuation -- )" } } }
|
||||
{ $values { "quot" { $quotation ( continuation -- ) } } }
|
||||
{ $description "Applies the quotation to the current continuation, which is reified from the point immediately after which the caller returns. The " { $link continue } " word resumes the continuation." } ;
|
||||
|
||||
HELP: callcc1
|
||||
{ $values { "quot" { $quotation "( continuation -- )" } } { "obj" "an object provided when resuming the continuation" } }
|
||||
{ $values { "quot" { $quotation ( continuation -- ) } } { "obj" "an object provided when resuming the continuation" } }
|
||||
{ $description "Applies the quotation to the current continuation, which is reified from the point immediately after which the caller returns. The " { $link continue-with } " word resumes the continuation, passing a value back to the original execution context." } ;
|
||||
|
||||
HELP: continue
|
||||
|
@ -170,11 +170,11 @@ HELP: throw
|
|||
{ cleanup recover } related-words
|
||||
|
||||
HELP: cleanup
|
||||
{ $values { "try" { $quotation "( ..a -- ..a )" } } { "cleanup-always" { $quotation "( ..a -- ..b )" } } { "cleanup-error" { $quotation "( ..b -- ..b )" } } }
|
||||
{ $values { "try" { $quotation ( ..a -- ..a ) } } { "cleanup-always" { $quotation ( ..a -- ..b ) } } { "cleanup-error" { $quotation ( ..b -- ..b ) } } }
|
||||
{ $description "Calls the " { $snippet "try" } " quotation. If no error is thrown, calls " { $snippet "cleanup-always" } " without restoring the data stack. If an error is thrown, restores the data stack, calls " { $snippet "cleanup-always" } " followed by " { $snippet "cleanup-error" } ", and rethrows the error." } ;
|
||||
|
||||
HELP: recover
|
||||
{ $values { "try" { $quotation "( ..a -- ..b )" } } { "recovery" { $quotation "( ..a error -- ..b )" } } }
|
||||
{ $values { "try" { $quotation ( ..a -- ..b ) } } { "recovery" { $quotation ( ..a error -- ..b ) } } }
|
||||
{ $description "Calls the " { $snippet "try" } " quotation. If an exception is thrown in the dynamic extent of the " { $snippet "try" } " quotation, restores the data stack and calls the " { $snippet "recovery" } " quotation to handle the error." } ;
|
||||
|
||||
HELP: ignore-errors
|
||||
|
|
|
@ -37,7 +37,7 @@ HELP: dispose*
|
|||
} ;
|
||||
|
||||
HELP: with-disposal
|
||||
{ $values { "object" "a disposable object" } { "quot" { $quotation "( object -- )" } } }
|
||||
{ $values { "object" "a disposable object" } { "quot" { $quotation ( object -- ) } } }
|
||||
{ $description "Calls the quotation, disposing the object with " { $link dispose } " after the quotation returns or if it throws an error." } ;
|
||||
|
||||
HELP: with-destructors
|
||||
|
|
|
@ -159,7 +159,7 @@ HELP: check-method
|
|||
{ $error-description "Thrown if " { $link POSTPONE: M: } " or " { $link create-method } " is given an invalid class or generic word." } ;
|
||||
|
||||
HELP: with-methods
|
||||
{ $values { "class" class } { "generic" generic } { "quot" { $quotation "( methods -- )" } } }
|
||||
{ $values { "class" class } { "generic" generic } { "quot" { $quotation ( methods -- ) } } }
|
||||
{ $description "Applies a quotation to the generic word's methods hashtable, and regenerates the generic word's definition when the quotation returns." }
|
||||
$low-level-note ;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ HELP: math-class-max
|
|||
} ;
|
||||
|
||||
HELP: math-upgrade
|
||||
{ $values { "class1" class } { "class2" class } { "quot" { $quotation "( n n -- n n )" } } }
|
||||
{ $values { "class1" class } { "class2" class } { "quot" { $quotation ( n n -- n n ) } } }
|
||||
{ $description "Outputs a quotation for upgrading numberical types. It takes two numbers on the stack, an instance of " { $snippet "class1" } ", and an instance of " { $snippet "class2" } ", and converts the one with the lower priority to the higher priority type." }
|
||||
{ $examples { $example "USING: generic.math math kernel prettyprint ;" "fixnum bignum math-upgrade ." "[ [ >bignum ] dip ]" } } ;
|
||||
|
||||
|
|
|
@ -306,11 +306,11 @@ HELP: lines
|
|||
{ $description "Reads lines of text until from the " { $link input-stream } " until it is exhausted, collecting them in a sequence of strings." } ;
|
||||
|
||||
HELP: each-line
|
||||
{ $values { "quot" { $quotation "( ... line -- ... )" } } }
|
||||
{ $values { "quot" { $quotation ( ... line -- ... ) } } }
|
||||
{ $description "Calls the quotation with successive lines of text, until the current " { $link input-stream } " is exhausted." } ;
|
||||
|
||||
HELP: each-block
|
||||
{ $values { "quot" { $quotation "( ... block -- ... )" } } }
|
||||
{ $values { "quot" { $quotation ( ... block -- ... ) } } }
|
||||
{ $description "Calls the quotation with successive blocks of data, until the current " { $link input-stream } " is exhausted." } ;
|
||||
|
||||
HELP: stream-contents
|
||||
|
|
|
@ -171,7 +171,7 @@ HELP: xor
|
|||
{ $notes "This word implements boolean exclusive or, so applying it to integers will not yield useful results (all integers have a true value). Bitwise exclusive or is the " { $link bitxor } " word." } ;
|
||||
|
||||
HELP: both?
|
||||
{ $values { "x" object } { "y" object } { "quot" { $quotation "( ... obj -- ... ? )" } } { "?" "a boolean" } }
|
||||
{ $values { "x" object } { "y" object } { "quot" { $quotation ( ... obj -- ... ? ) } } { "?" "a boolean" } }
|
||||
{ $description "Tests if the quotation yields a true value when applied to both " { $snippet "x" } " and " { $snippet "y" } "." }
|
||||
{ $examples
|
||||
{ $example "USING: kernel math prettyprint ;" "3 5 [ odd? ] both? ." "t" }
|
||||
|
@ -179,7 +179,7 @@ HELP: both?
|
|||
} ;
|
||||
|
||||
HELP: either?
|
||||
{ $values { "x" object } { "y" object } { "quot" { $quotation "( ... obj -- ... ? )" } } { "?" "a boolean" } }
|
||||
{ $values { "x" object } { "y" object } { "quot" { $quotation ( ... obj -- ... ? ) } } { "?" "a boolean" } }
|
||||
{ $description "Tests if the quotation yields a true value when applied to either " { $snippet "x" } " or " { $snippet "y" } "." }
|
||||
{ $examples
|
||||
{ $example "USING: kernel math prettyprint ;" "3 6 [ odd? ] either? ." "t" }
|
||||
|
@ -187,7 +187,7 @@ HELP: either?
|
|||
} ;
|
||||
|
||||
HELP: same?
|
||||
{ $values { "x" object } { "y" object } { "quot" { $quotation "( ... obj -- ... obj' )" } } { "?" "a boolean" } }
|
||||
{ $values { "x" object } { "y" object } { "quot" { $quotation ( ... obj -- ... obj' ) } } { "?" "a boolean" } }
|
||||
{ $description "Applies the quotation to both " { $snippet "x" } " and " { $snippet "y" } ", and then checks if the results are equal." }
|
||||
{ $examples
|
||||
{ $example "USING: kernel math prettyprint ;" "4 5 [ 2/ ] same? ." "t" }
|
||||
|
@ -219,22 +219,22 @@ HELP: call
|
|||
{ call POSTPONE: call( } related-words
|
||||
|
||||
HELP: keep
|
||||
{ $values { "x" object } { "quot" { $quotation "( ..a x -- ..b )" } } }
|
||||
{ $values { "x" object } { "quot" { $quotation ( ..a x -- ..b ) } } }
|
||||
{ $description "Call a quotation with a value on the stack, restoring the value when the quotation returns." }
|
||||
{ $examples
|
||||
{ $example "USING: arrays kernel prettyprint ;" "2 \"greetings\" [ <array> ] keep 2array ." "{ { \"greetings\" \"greetings\" } \"greetings\" }" }
|
||||
} ;
|
||||
|
||||
HELP: 2keep
|
||||
{ $values { "x" object } { "y" object } { "quot" { $quotation "( ..a x y -- ..b )" } } }
|
||||
{ $values { "x" object } { "y" object } { "quot" { $quotation ( ..a x y -- ..b ) } } }
|
||||
{ $description "Call a quotation with two values on the stack, restoring the values when the quotation returns." } ;
|
||||
|
||||
HELP: 3keep
|
||||
{ $values { "x" object } { "y" object } { "z" object } { "quot" { $quotation "( ..a x y z -- ..b )" } } }
|
||||
{ $values { "x" object } { "y" object } { "z" object } { "quot" { $quotation ( ..a x y z -- ..b ) } } }
|
||||
{ $description "Call a quotation with three values on the stack, restoring the values when the quotation returns." } ;
|
||||
|
||||
HELP: bi
|
||||
{ $values { "x" object } { "p" { $quotation "( ..a x -- ..b )" } } { "q" { $quotation "( ..c x -- ..d )" } } }
|
||||
{ $values { "x" object } { "p" { $quotation ( ..a x -- ..b ) } } { "q" { $quotation ( ..c x -- ..d ) } } }
|
||||
{ $description "Applies " { $snippet "p" } " to " { $snippet "x" } ", then applies " { $snippet "q" } " to " { $snippet "x" } "." }
|
||||
{ $examples
|
||||
"If " { $snippet "[ p ]" } " and " { $snippet "[ q ]" } " have stack effect " { $snippet "( x -- )" } ", then the following two lines are equivalent:"
|
||||
|
@ -256,7 +256,7 @@ HELP: bi
|
|||
} ;
|
||||
|
||||
HELP: 2bi
|
||||
{ $values { "x" object } { "y" object } { "p" { $quotation "( x y -- ... )" } } { "q" { $quotation "( x y -- ... )" } } }
|
||||
{ $values { "x" object } { "y" object } { "p" { $quotation ( x y -- ... ) } } { "q" { $quotation ( x y -- ... ) } } }
|
||||
{ $description "Applies " { $snippet "p" } " to the two input values, then applies " { $snippet "q" } " to the two input values." }
|
||||
{ $examples
|
||||
"If " { $snippet "[ p ]" } " and " { $snippet "[ q ]" } " have stack effect " { $snippet "( x y -- )" } ", then the following two lines are equivalent:"
|
||||
|
@ -277,7 +277,7 @@ HELP: 2bi
|
|||
} ;
|
||||
|
||||
HELP: 3bi
|
||||
{ $values { "x" object } { "y" object } { "z" object } { "p" { $quotation "( x y z -- ... )" } } { "q" { $quotation "( x y z -- ... )" } } }
|
||||
{ $values { "x" object } { "y" object } { "z" object } { "p" { $quotation ( x y z -- ... ) } } { "q" { $quotation ( x y z -- ... ) } } }
|
||||
{ $description "Applies " { $snippet "p" } " to the three input values, then applies " { $snippet "q" } " to the three input values." }
|
||||
{ $examples
|
||||
"If " { $snippet "[ p ]" } " and " { $snippet "[ q ]" } " have stack effect " { $snippet "( x y z -- )" } ", then the following two lines are equivalent:"
|
||||
|
@ -293,7 +293,7 @@ HELP: 3bi
|
|||
} ;
|
||||
|
||||
HELP: tri
|
||||
{ $values { "x" object } { "p" { $quotation "( x -- ... )" } } { "q" { $quotation "( x -- ... )" } } { "r" { $quotation "( x -- ... )" } } }
|
||||
{ $values { "x" object } { "p" { $quotation ( x -- ... ) } } { "q" { $quotation ( x -- ... ) } } { "r" { $quotation ( x -- ... ) } } }
|
||||
{ $description "Applies " { $snippet "p" } " to " { $snippet "x" } ", then applies " { $snippet "q" } " to " { $snippet "x" } ", and finally applies " { $snippet "r" } " to " { $snippet "x" } "." }
|
||||
{ $examples
|
||||
"If " { $snippet "[ p ]" } ", " { $snippet "[ q ]" } " and " { $snippet "[ r ]" } " have stack effect " { $snippet "( x -- )" } ", then the following two lines are equivalent:"
|
||||
|
@ -314,7 +314,7 @@ HELP: tri
|
|||
} ;
|
||||
|
||||
HELP: 2tri
|
||||
{ $values { "x" object } { "y" object } { "p" { $quotation "( x y -- ... )" } } { "q" { $quotation "( x y -- ... )" } } { "r" { $quotation "( x y -- ... )" } } }
|
||||
{ $values { "x" object } { "y" object } { "p" { $quotation ( x y -- ... ) } } { "q" { $quotation ( x y -- ... ) } } { "r" { $quotation ( x y -- ... ) } } }
|
||||
{ $description "Applies " { $snippet "p" } " to the two input values, then applies " { $snippet "q" } " to the two input values, and finally applies " { $snippet "r" } " to the two input values." }
|
||||
{ $examples
|
||||
"If " { $snippet "[ p ]" } ", " { $snippet "[ q ]" } " and " { $snippet "[ r ]" } " have stack effect " { $snippet "( x y -- )" } ", then the following two lines are equivalent:"
|
||||
|
@ -330,7 +330,7 @@ HELP: 2tri
|
|||
} ;
|
||||
|
||||
HELP: 3tri
|
||||
{ $values { "x" object } { "y" object } { "z" object } { "p" { $quotation "( x y z -- ... )" } } { "q" { $quotation "( x y z -- ... )" } } { "r" { $quotation "( x y z -- ... )" } } }
|
||||
{ $values { "x" object } { "y" object } { "z" object } { "p" { $quotation ( x y z -- ... ) } } { "q" { $quotation ( x y z -- ... ) } } { "r" { $quotation ( x y z -- ... ) } } }
|
||||
{ $description "Applies " { $snippet "p" } " to the three input values, then applies " { $snippet "q" } " to the three input values, and finally applies " { $snippet "r" } " to the three input values." }
|
||||
{ $examples
|
||||
"If " { $snippet "[ p ]" } ", " { $snippet "[ q ]" } " and " { $snippet "[ r ]" } " have stack effect " { $snippet "( x y z -- )" } ", then the following two lines are equivalent:"
|
||||
|
@ -347,7 +347,7 @@ HELP: 3tri
|
|||
|
||||
|
||||
HELP: bi*
|
||||
{ $values { "x" object } { "y" object } { "p" { $quotation "( x -- ... )" } } { "q" { $quotation "( y -- ... )" } } }
|
||||
{ $values { "x" object } { "y" object } { "p" { $quotation ( x -- ... ) } } { "q" { $quotation ( y -- ... ) } } }
|
||||
{ $description "Applies " { $snippet "p" } " to " { $snippet "x" } ", then applies " { $snippet "q" } " to " { $snippet "y" } "." }
|
||||
{ $examples
|
||||
"The following two lines are equivalent:"
|
||||
|
@ -358,7 +358,7 @@ HELP: bi*
|
|||
} ;
|
||||
|
||||
HELP: 2bi*
|
||||
{ $values { "w" object } { "x" object } { "y" object } { "z" object } { "p" { $quotation "( w x -- ... )" } } { "q" { $quotation "( y z -- ... )" } } }
|
||||
{ $values { "w" object } { "x" object } { "y" object } { "z" object } { "p" { $quotation ( w x -- ... ) } } { "q" { $quotation ( y z -- ... ) } } }
|
||||
{ $description "Applies " { $snippet "p" } " to " { $snippet "w" } " and " { $snippet "x" } ", then applies " { $snippet "q" } " to " { $snippet "y" } " and " { $snippet "z" } "." }
|
||||
{ $examples
|
||||
"The following two lines are equivalent:"
|
||||
|
@ -369,7 +369,7 @@ HELP: 2bi*
|
|||
} ;
|
||||
|
||||
HELP: 2tri*
|
||||
{ $values { "u" object } { "v" object } { "w" object } { "x" object } { "y" object } { "z" object } { "p" { $quotation "( u v -- ... )" } } { "q" { $quotation "( w x -- ... )" } } { "r" { $quotation "( y z -- ... )" } } }
|
||||
{ $values { "u" object } { "v" object } { "w" object } { "x" object } { "y" object } { "z" object } { "p" { $quotation ( u v -- ... ) } } { "q" { $quotation ( w x -- ... ) } } { "r" { $quotation ( y z -- ... ) } } }
|
||||
{ $description "Applies " { $snippet "p" } " to " { $snippet "u" } " and " { $snippet "v" } ", then applies " { $snippet "q" } " to " { $snippet "w" } " and " { $snippet "x" } ", and finally applies " { $snippet "r" } " to " { $snippet "y" } " and " { $snippet "z" } "." }
|
||||
{ $examples
|
||||
"The following two lines are equivalent:"
|
||||
|
@ -380,7 +380,7 @@ HELP: 2tri*
|
|||
} ;
|
||||
|
||||
HELP: tri*
|
||||
{ $values { "x" object } { "y" object } { "z" object } { "p" { $quotation "( x -- ... )" } } { "q" { $quotation "( y -- ... )" } } { "r" { $quotation "( z -- ... )" } } }
|
||||
{ $values { "x" object } { "y" object } { "z" object } { "p" { $quotation ( x -- ... ) } } { "q" { $quotation ( y -- ... ) } } { "r" { $quotation ( z -- ... ) } } }
|
||||
{ $description "Applies " { $snippet "p" } " to " { $snippet "x" } ", then applies " { $snippet "q" } " to " { $snippet "y" } ", and finally applies " { $snippet "r" } " to " { $snippet "z" } "." }
|
||||
{ $examples
|
||||
"The following two lines are equivalent:"
|
||||
|
@ -391,7 +391,7 @@ HELP: tri*
|
|||
} ;
|
||||
|
||||
HELP: bi@
|
||||
{ $values { "x" object } { "y" object } { "quot" { $quotation "( obj -- ... )" } } }
|
||||
{ $values { "x" object } { "y" object } { "quot" { $quotation ( obj -- ... ) } } }
|
||||
{ $description "Applies the quotation to " { $snippet "x" } ", then to " { $snippet "y" } "." }
|
||||
{ $examples
|
||||
"The following two lines are equivalent:"
|
||||
|
@ -407,7 +407,7 @@ HELP: bi@
|
|||
} ;
|
||||
|
||||
HELP: 2bi@
|
||||
{ $values { "w" object } { "x" object } { "y" object } { "z" object } { "quot" { $quotation "( obj1 obj2 -- ... )" } } }
|
||||
{ $values { "w" object } { "x" object } { "y" object } { "z" object } { "quot" { $quotation ( obj1 obj2 -- ... ) } } }
|
||||
{ $description "Applies the quotation to " { $snippet "w" } " and " { $snippet "x" } ", then to " { $snippet "y" } " and " { $snippet "z" } "." }
|
||||
{ $examples
|
||||
"The following two lines are equivalent:"
|
||||
|
@ -423,7 +423,7 @@ HELP: 2bi@
|
|||
} ;
|
||||
|
||||
HELP: tri@
|
||||
{ $values { "x" object } { "y" object } { "z" object } { "quot" { $quotation "( obj -- ... )" } } }
|
||||
{ $values { "x" object } { "y" object } { "z" object } { "quot" { $quotation ( obj -- ... ) } } }
|
||||
{ $description "Applies the quotation to " { $snippet "x" } ", then to " { $snippet "y" } ", and finally to " { $snippet "z" } "." }
|
||||
{ $examples
|
||||
"The following two lines are equivalent:"
|
||||
|
@ -439,7 +439,7 @@ HELP: tri@
|
|||
} ;
|
||||
|
||||
HELP: 2tri@
|
||||
{ $values { "u" object } { "v" object } { "w" object } { "x" object } { "y" object } { "z" object } { "quot" { $quotation "( obj1 obj2 -- ... )" } } }
|
||||
{ $values { "u" object } { "v" object } { "w" object } { "x" object } { "y" object } { "z" object } { "quot" { $quotation ( obj1 obj2 -- ... ) } } }
|
||||
{ $description "Applies the quotation to " { $snippet "u" } " and " { $snippet "v" } ", then to " { $snippet "w" } " and " { $snippet "x" } ", and then to " { $snippet "y" } " and " { $snippet "z" } "." }
|
||||
{ $examples
|
||||
"The following two lines are equivalent:"
|
||||
|
@ -455,7 +455,7 @@ HELP: 2tri@
|
|||
} ;
|
||||
|
||||
HELP: bi-curry
|
||||
{ $values { "x" object } { "p" { $quotation "( x -- ... )" } } { "q" { $quotation "( x -- ... )" } } { "p'" { $snippet "[ x p ]" } } { "q'" { $snippet "[ x q ]" } } }
|
||||
{ $values { "x" object } { "p" { $quotation ( x -- ... ) } } { "q" { $quotation ( x -- ... ) } } { "p'" { $snippet "[ x p ]" } } { "q'" { $snippet "[ x q ]" } } }
|
||||
{ $description "Partially applies " { $snippet "p" } " and " { $snippet "q" } " to " { $snippet "x" } "." }
|
||||
{ $notes
|
||||
"The following two lines are equivalent:"
|
||||
|
@ -479,9 +479,9 @@ HELP: bi-curry
|
|||
HELP: tri-curry
|
||||
{ $values
|
||||
{ "x" object }
|
||||
{ "p" { $quotation "( x -- ... )" } }
|
||||
{ "q" { $quotation "( x -- ... )" } }
|
||||
{ "r" { $quotation "( x -- ... )" } }
|
||||
{ "p" { $quotation ( x -- ... ) } }
|
||||
{ "q" { $quotation ( x -- ... ) } }
|
||||
{ "r" { $quotation ( x -- ... ) } }
|
||||
{ "p'" { $snippet "[ x p ]" } }
|
||||
{ "q'" { $snippet "[ x q ]" } }
|
||||
{ "r'" { $snippet "[ x r ]" } }
|
||||
|
@ -501,7 +501,7 @@ HELP: tri-curry
|
|||
"The combination " { $snippet "tri-curry tri*" } " cannot be expressed with the non-currying dataflow combinators alone; it handles the case where you have four values " { $snippet "a b c d" } " on the stack, and you wish to apply " { $snippet "p" } " to " { $snippet "a d" } ", " { $snippet "q" } " to " { $snippet "b d" } " and " { $snippet "r" } " to " { $snippet "c d" } "." } ;
|
||||
|
||||
HELP: bi-curry*
|
||||
{ $values { "x" object } { "y" object } { "p" { $quotation "( x -- ... )" } } { "q" { $quotation "( y -- ... )" } } { "p'" { $snippet "[ x p ]" } } { "q'" { $snippet "[ y q ]" } } }
|
||||
{ $values { "x" object } { "y" object } { "p" { $quotation ( x -- ... ) } } { "q" { $quotation ( y -- ... ) } } { "p'" { $snippet "[ x p ]" } } { "q'" { $snippet "[ y q ]" } } }
|
||||
{ $description "Partially applies " { $snippet "p" } " to " { $snippet "x" } ", and " { $snippet "q" } " to " { $snippet "y" } "." }
|
||||
{ $notes
|
||||
"The following two lines are equivalent:"
|
||||
|
@ -530,9 +530,9 @@ HELP: tri-curry*
|
|||
{ "x" object }
|
||||
{ "y" object }
|
||||
{ "z" object }
|
||||
{ "p" { $quotation "( x -- ... )" } }
|
||||
{ "q" { $quotation "( y -- ... )" } }
|
||||
{ "r" { $quotation "( z -- ... )" } }
|
||||
{ "p" { $quotation ( x -- ... ) } }
|
||||
{ "q" { $quotation ( y -- ... ) } }
|
||||
{ "r" { $quotation ( z -- ... ) } }
|
||||
{ "p'" { $snippet "[ x p ]" } }
|
||||
{ "q'" { $snippet "[ y q ]" } }
|
||||
{ "r'" { $snippet "[ z r ]" } }
|
||||
|
@ -552,7 +552,7 @@ HELP: tri-curry*
|
|||
} ;
|
||||
|
||||
HELP: bi-curry@
|
||||
{ $values { "x" object } { "y" object } { "q" { $quotation "( obj -- ... )" } } { "p'" { $snippet "[ x q ]" } } { "q'" { $snippet "[ y q ]" } } }
|
||||
{ $values { "x" object } { "y" object } { "q" { $quotation ( obj -- ... ) } } { "p'" { $snippet "[ x q ]" } } { "q'" { $snippet "[ y q ]" } } }
|
||||
{ $description "Partially applies " { $snippet "q" } " to " { $snippet "x" } " and " { $snippet "y" } "." }
|
||||
{ $notes
|
||||
"The following two lines are equivalent:"
|
||||
|
@ -567,7 +567,7 @@ HELP: tri-curry@
|
|||
{ "x" object }
|
||||
{ "y" object }
|
||||
{ "z" object }
|
||||
{ "q" { $quotation "( obj -- ... )" } }
|
||||
{ "q" { $quotation ( obj -- ... ) } }
|
||||
{ "p'" { $snippet "[ x q ]" } }
|
||||
{ "q'" { $snippet "[ y q ]" } }
|
||||
{ "r'" { $snippet "[ z q ]" } }
|
||||
|
@ -633,7 +633,7 @@ $nl
|
|||
} ;
|
||||
|
||||
HELP: if*
|
||||
{ $values { "?" "a generalized boolean" } { "true" { $quotation "( ..a ? -- ..b )" } } { "false" { $quotation "( ..a -- ..b )" } } }
|
||||
{ $values { "?" "a generalized boolean" } { "true" { $quotation ( ..a ? -- ..b ) } } { "false" { $quotation ( ..a -- ..b ) } } }
|
||||
{ $description "Alternative conditional form that preserves the " { $snippet "cond" } " value if it is true."
|
||||
$nl
|
||||
"If the condition is true, it is retained on the stack before the " { $snippet "true" } " quotation is called. Otherwise, the condition is removed from the stack and the " { $snippet "false" } " quotation is called."
|
||||
|
@ -666,21 +666,21 @@ $nl
|
|||
} ;
|
||||
|
||||
HELP: when*
|
||||
{ $values { "?" "a generalized boolean" } { "true" { $quotation "( ..a ? -- ..a )" } } }
|
||||
{ $values { "?" "a generalized boolean" } { "true" { $quotation ( ..a ? -- ..a ) } } }
|
||||
{ $description "Variant of " { $link if* } " with no false quotation."
|
||||
$nl
|
||||
"The following two lines are equivalent:"
|
||||
{ $code "X [ Y ] when*" "X dup [ Y ] [ drop ] if" } } ;
|
||||
|
||||
HELP: unless*
|
||||
{ $values { "?" "a generalized boolean" } { "false" { $quotation "( ..a -- ..a x )" } } { "x" object } }
|
||||
{ $values { "?" "a generalized boolean" } { "false" { $quotation ( ..a -- ..a x ) } } { "x" object } }
|
||||
{ $description "Variant of " { $link if* } " with no true quotation." }
|
||||
{ $notes
|
||||
"The following two lines are equivalent:"
|
||||
{ $code "X [ Y ] unless*" "X dup [ ] [ drop Y ] if" } } ;
|
||||
|
||||
HELP: ?if
|
||||
{ $values { "default" object } { "cond" "a generalized boolean" } { "true" { $quotation "( ..a cond -- ..b )" } } { "false" { $quotation "( ..a default -- ..b )" } } }
|
||||
{ $values { "default" object } { "cond" "a generalized boolean" } { "true" { $quotation ( ..a cond -- ..b ) } } { "false" { $quotation ( ..a default -- ..b ) } } }
|
||||
{ $description "If the condition is " { $link f } ", the " { $snippet "false" } " quotation is called with the " { $snippet "default" } " value on the stack. Otherwise, the " { $snippet "true" } " quotation is called with the condition on the stack." }
|
||||
{ $notes
|
||||
"The following two lines are equivalent:"
|
||||
|
@ -740,7 +740,7 @@ HELP: null
|
|||
} ;
|
||||
|
||||
HELP: most
|
||||
{ $values { "x" object } { "y" object } { "quot" { $quotation "( x y -- ? )" } } { "z" "either " { $snippet "x" } " or " { $snippet "y" } } }
|
||||
{ $values { "x" object } { "y" object } { "quot" { $quotation ( x y -- ? ) } } { "z" "either " { $snippet "x" } " or " { $snippet "y" } } }
|
||||
{ $description "If the quotation yields a true value when applied to " { $snippet "x" } " and " { $snippet "y" } ", outputs " { $snippet "x" } ", otherwise outputs " { $snippet "y" } "." } ;
|
||||
|
||||
HELP: curry
|
||||
|
@ -770,7 +770,7 @@ HELP: 3curry
|
|||
{ $notes "This operation is efficient and does not copy the quotation." } ;
|
||||
|
||||
HELP: with
|
||||
{ $values { "param" object } { "obj" object } { "quot" { $quotation "( param elt -- ... )" } } { "curry" curry } }
|
||||
{ $values { "param" object } { "obj" object } { "quot" { $quotation ( param elt -- ... ) } } { "curry" curry } }
|
||||
{ $description "Partial application on the left. The following two lines are equivalent:"
|
||||
{ $code "swap [ swap A ] curry B" }
|
||||
{ $code "[ A ] with B" }
|
||||
|
@ -835,15 +835,15 @@ HELP: 4dip
|
|||
} ;
|
||||
|
||||
HELP: while
|
||||
{ $values { "pred" { $quotation "( ..a -- ..b ? )" } } { "body" { $quotation "( ..b -- ..a )" } } }
|
||||
{ $values { "pred" { $quotation ( ..a -- ..b ? ) } } { "body" { $quotation ( ..b -- ..a ) } } }
|
||||
{ $description "Calls " { $snippet "body" } " until " { $snippet "pred" } " returns " { $link f } "." } ;
|
||||
|
||||
HELP: until
|
||||
{ $values { "pred" { $quotation "( ..a -- ..b ? )" } } { "body" { $quotation "( ..b -- ..a )" } } }
|
||||
{ $values { "pred" { $quotation ( ..a -- ..b ? ) } } { "body" { $quotation ( ..b -- ..a ) } } }
|
||||
{ $description "Calls " { $snippet "body" } " until " { $snippet "pred" } " returns " { $link t } "." } ;
|
||||
|
||||
HELP: do
|
||||
{ $values { "pred" { $quotation "( ..a -- ..b ? )" } } { "body" { $quotation "( ..b -- ..a )" } } }
|
||||
{ $values { "pred" { $quotation ( ..a -- ..b ? ) } } { "body" { $quotation ( ..b -- ..a ) } } }
|
||||
{ $description "Executes one iteration of a " { $link while } " or " { $link until } " loop." } ;
|
||||
|
||||
HELP: loop
|
||||
|
|
|
@ -32,7 +32,7 @@ HELP: skip
|
|||
{ $description "Skips to the first space character (if " { $snippet "boolean" } " is " { $link f } ") or the first non-space character (otherwise). Tabulations used as separators instead of spaces will be flagged as an error." } ;
|
||||
|
||||
HELP: change-lexer-column
|
||||
{ $values { "lexer" lexer } { "quot" { $quotation "( col line -- newcol )" } } }
|
||||
{ $values { "lexer" lexer } { "quot" { $quotation ( col line -- newcol ) } } }
|
||||
{ $description "Applies a quotation to the current column and line text to produce a new column, and moves the lexer position." } ;
|
||||
|
||||
HELP: skip-blank
|
||||
|
@ -72,13 +72,13 @@ HELP: still-parsing?
|
|||
{ $description "Outputs " { $link f } " if end of input has been reached, " { $link t } " otherwise." } ;
|
||||
|
||||
HELP: each-token
|
||||
{ $values { "end" string } { "quot" { $quotation "( ... token -- ... )" } } }
|
||||
{ $values { "end" string } { "quot" { $quotation ( ... token -- ... ) } } }
|
||||
{ $description "Reads a sequence of tokens until the first occurrence of " { $snippet "end" } ". " { $snippet "quot" } " is called on each token as it is read." }
|
||||
{ $examples "This word is used to implement " { $link POSTPONE: USING: } "." }
|
||||
$parsing-note ;
|
||||
|
||||
HELP: map-tokens
|
||||
{ $values { "end" string } { "quot" { $quotation "( ... token -- ... elt )" } } { "seq" "a new sequence of " { $snippet "object" } "s" } }
|
||||
{ $values { "end" string } { "quot" { $quotation ( ... token -- ... elt ) } } { "seq" "a new sequence of " { $snippet "object" } "s" } }
|
||||
{ $description "Reads a sequence of tokens until the first occurrence of " { $snippet "end" } ". " { $snippet "quot" } " is called on each token as it is read, and the results are collected into a new output sequence." }
|
||||
$parsing-note ;
|
||||
|
||||
|
|
|
@ -414,22 +414,22 @@ HELP: power-of-2?
|
|||
{ $description "Tests if " { $snippet "n" } " is a power of 2." } ;
|
||||
|
||||
HELP: each-integer
|
||||
{ $values { "n" integer } { "quot" { $quotation "( ... i -- ... )" } } }
|
||||
{ $values { "n" integer } { "quot" { $quotation ( ... i -- ... ) } } }
|
||||
{ $description "Applies the quotation to each integer from 0 up to " { $snippet "n" } ", excluding " { $snippet "n" } "." }
|
||||
{ $notes "This word is used to implement " { $link each } "." } ;
|
||||
|
||||
HELP: all-integers?
|
||||
{ $values { "n" integer } { "quot" { $quotation "( ... i -- ... ? )" } } { "?" "a boolean" } }
|
||||
{ $values { "n" integer } { "quot" { $quotation ( ... i -- ... ? ) } } { "?" "a boolean" } }
|
||||
{ $description "Applies the quotation to each integer from 0 up to " { $snippet "n" } ", excluding " { $snippet "n" } ". Iteration stops when the quotation outputs " { $link f } " or the end is reached. If the quotation yields a false value for some integer, this word outputs " { $link f } ". Otherwise, this word outputs " { $link t } "." }
|
||||
{ $notes "This word is used to implement " { $link all? } "." } ;
|
||||
|
||||
HELP: find-integer
|
||||
{ $values { "n" integer } { "quot" { $quotation "( ... i -- ... ? )" } } { "i" "an integer or " { $link f } } }
|
||||
{ $values { "n" integer } { "quot" { $quotation ( ... i -- ... ? ) } } { "i" "an integer or " { $link f } } }
|
||||
{ $description "Applies the quotation to each integer from 0 up to " { $snippet "n" } ", excluding " { $snippet "n" } ". Iteration stops when the quotation outputs a true value or the end is reached. If the quotation yields a true value for some integer, this word outputs that integer. Otherwise, this word outputs " { $link f } "." }
|
||||
{ $notes "This word is used to implement " { $link find } "." } ;
|
||||
|
||||
HELP: find-last-integer
|
||||
{ $values { "n" integer } { "quot" { $quotation "( ... i -- ... ? )" } } { "i" "an integer or " { $link f } } }
|
||||
{ $values { "n" integer } { "quot" { $quotation ( ... i -- ... ? ) } } { "i" "an integer or " { $link f } } }
|
||||
{ $description "Applies the quotation to each integer from " { $snippet "n" } " down to 0, inclusive. Iteration stops when the quotation outputs a true value or 0 is reached. If the quotation yields a true value for some integer, the word outputs that integer. Otherwise, the word outputs " { $link f } "." }
|
||||
{ $notes "This word is used to implement " { $link find-last } "." } ;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ HELP: invert-comparison
|
|||
{ $example "USING: math.order prettyprint ;" "+lt+ invert-comparison ." "+gt+" } } ;
|
||||
|
||||
HELP: compare
|
||||
{ $values { "obj1" object } { "obj2" object } { "quot" { $quotation "( obj -- newobj )" } } { "<=>" "an ordering specifier" } }
|
||||
{ $values { "obj1" object } { "obj2" object } { "quot" { $quotation ( obj -- newobj ) } } { "<=>" "an ordering specifier" } }
|
||||
{ $description "Compares the results of applying the quotation to both objects via " { $link <=> } "." }
|
||||
{ $examples { $example "USING: kernel math.order prettyprint sequences ;" "\"hello\" \"hi\" [ length ] compare ." "+gt+" }
|
||||
} ;
|
||||
|
|
|
@ -3,7 +3,7 @@ quotations math ;
|
|||
IN: memory
|
||||
|
||||
HELP: instances
|
||||
{ $values { "quot" { $quotation "( obj -- ? )" } } { "seq" "a fresh sequence" } }
|
||||
{ $values { "quot" { $quotation ( obj -- ? ) } } { "seq" "a fresh sequence" } }
|
||||
{ $description "Outputs a sequence of all objects in the heap which satisfy the quotation." } ;
|
||||
|
||||
HELP: gc
|
||||
|
|
|
@ -85,12 +85,12 @@ HELP: on
|
|||
{ $side-effects "variable" } ;
|
||||
|
||||
HELP: change
|
||||
{ $values { "variable" "a variable, by convention a symbol" } { "quot" { $quotation "( old -- new )" } } }
|
||||
{ $values { "variable" "a variable, by convention a symbol" } { "quot" { $quotation ( old -- new ) } } }
|
||||
{ $description "Applies the quotation to the old value of the variable, and assigns the resulting value to the variable." }
|
||||
{ $side-effects "variable" } ;
|
||||
|
||||
HELP: change-global
|
||||
{ $values { "variable" "a variable, by convention a symbol" } { "quot" { $quotation "( old -- new )" } } }
|
||||
{ $values { "variable" "a variable, by convention a symbol" } { "quot" { $quotation ( old -- new ) } } }
|
||||
{ $description "Applies the quotation to the old value of the global variable, and assigns the resulting value to the global variable." }
|
||||
{ $side-effects "variable" } ;
|
||||
|
||||
|
|
|
@ -222,7 +222,7 @@ HELP: parse-lines
|
|||
{ $errors "Throws a " { $link lexer-error } " if the input is malformed." } ;
|
||||
|
||||
HELP: parse-literal
|
||||
{ $values { "accum" vector } { "end" word } { "quot" { $quotation "( seq -- obj )" } } }
|
||||
{ $values { "accum" vector } { "end" word } { "quot" { $quotation ( seq -- obj ) } } }
|
||||
{ $description "Parses objects from parser input until " { $snippet "end" } ", applies the quotation to the resulting sequence, and adds the output value to the accumulator." }
|
||||
{ $examples "This word is used to implement " { $link POSTPONE: [ } "." }
|
||||
$parsing-note ;
|
||||
|
|
|
@ -284,7 +284,7 @@ HELP: set-array-nth
|
|||
{ $warning "This word is in the " { $vocab-link "sequences.private" } " vocabulary because it is unsafe. It does not check types or array bounds, and improper use can corrupt memory. User code must use " { $link set-nth } " instead." } ;
|
||||
|
||||
HELP: collect
|
||||
{ $values { "n" "a non-negative integer" } { "quot" { $quotation "( ... n -- ... value )" } } { "into" "a sequence of length at least " { $snippet "n" } } }
|
||||
{ $values { "n" "a non-negative integer" } { "quot" { $quotation ( ... n -- ... value ) } } { "into" "a sequence of length at least " { $snippet "n" } } }
|
||||
{ $description "A primitive mapping operation that applies a quotation to all integers from 0 up to but not including " { $snippet "n" } ", and collects the results in a new array. User code should use " { $link map } " instead." }
|
||||
{ $examples
|
||||
{ $example
|
||||
|
@ -295,11 +295,11 @@ HELP: collect
|
|||
} ;
|
||||
|
||||
HELP: each
|
||||
{ $values { "seq" sequence } { "quot" { $quotation "( ... x -- ... )" } } }
|
||||
{ $values { "seq" sequence } { "quot" { $quotation ( ... x -- ... ) } } }
|
||||
{ $description "Applies the quotation to each element of the sequence in order." } ;
|
||||
|
||||
HELP: reduce
|
||||
{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation "( ... prev elt -- ... next )" } } { "result" "the final result" } }
|
||||
{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation ( ... prev elt -- ... next ) } } { "result" "the final result" } }
|
||||
{ $description "Combines successive elements of the sequence using a binary operation, and outputs the final result. On the first iteration, the two inputs to the quotation are " { $snippet "identity" } ", and the first element of the sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the corresponding element of the sequence." }
|
||||
{ $examples
|
||||
{ $example "USING: math prettyprint sequences ;" "{ 1 5 3 } 0 [ + ] reduce ." "9" }
|
||||
|
@ -307,7 +307,7 @@ HELP: reduce
|
|||
|
||||
HELP: reduce-index
|
||||
{ $values
|
||||
{ "seq" sequence } { "identity" object } { "quot" { $quotation "( ... prev elt index -- ... next )" } } { "result" object } }
|
||||
{ "seq" sequence } { "identity" object } { "quot" { $quotation ( ... prev elt index -- ... next ) } } { "result" object } }
|
||||
{ $description "Combines successive elements of the sequence and their indices binary operations, and outputs the final result. On the first iteration, the three inputs to the quotation are " { $snippet "identity" } ", the first element of the sequence, and its index, 0. On successive iterations, the first input is the result of the previous iteration, the second input is the corresponding element of the sequence, and the third is its index." }
|
||||
{ $examples { $example "USING: sequences prettyprint math ;"
|
||||
"{ 10 50 90 } 0 [ + + ] reduce-index ."
|
||||
|
@ -315,7 +315,7 @@ HELP: reduce-index
|
|||
} } ;
|
||||
|
||||
HELP: accumulate-as
|
||||
{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation "( ... prev elt -- ... next )" } } { "exemplar" sequence } { "final" "the final result" } { "newseq" "a new sequence" } }
|
||||
{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation ( ... prev elt -- ... next ) } } { "exemplar" sequence } { "final" "the final result" } { "newseq" "a new sequence" } }
|
||||
{ $description "Combines successive elements of the sequence using a binary operation, and outputs a sequence of the same type as " { $snippet "exemplar" } " containing intermediate results, together with the final result."
|
||||
$nl
|
||||
"The first element of the new sequence is " { $snippet "identity" } ". Then, on the first iteration, the two inputs to the quotation are " { $snippet "identity" } ", and the first element of the old sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the corresponding element of the old sequence."
|
||||
|
@ -323,7 +323,7 @@ $nl
|
|||
"When given the empty sequence, outputs an empty sequence together with the " { $snippet "identity" } "." } ;
|
||||
|
||||
HELP: accumulate
|
||||
{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation "( ... prev elt -- ... next )" } } { "final" "the final result" } { "newseq" "a new array" } }
|
||||
{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation ( ... prev elt -- ... next ) } } { "final" "the final result" } { "newseq" "a new array" } }
|
||||
{ $description "Combines successive elements of the sequence using a binary operation, and outputs a sequence of intermediate results, together with the final result."
|
||||
$nl
|
||||
"The first element of the new sequence is " { $snippet "identity" } ". Then, on the first iteration, the two inputs to the quotation are " { $snippet "identity" } ", and the first element of the old sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the corresponding element of the old sequence."
|
||||
|
@ -334,7 +334,7 @@ $nl
|
|||
} ;
|
||||
|
||||
HELP: accumulate!
|
||||
{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation "( ... prev elt -- ... next )" } } { "final" "the final result" } }
|
||||
{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation ( ... prev elt -- ... next ) } } { "final" "the final result" } }
|
||||
{ $description "Combines successive elements of the sequence using a binary operation, and outputs the original sequence of intermediate results, together with the final result."
|
||||
$nl
|
||||
"The first element of the new sequence is " { $snippet "identity" } ". Then, on the first iteration, the two inputs to the quotation are " { $snippet "identity" } ", and the first element of the old sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the corresponding element of the old sequence."
|
||||
|
@ -345,11 +345,11 @@ $nl
|
|||
} ;
|
||||
|
||||
HELP: map
|
||||
{ $values { "seq" sequence } { "quot" { $quotation "( ... elt -- ... newelt )" } } { "newseq" "a new sequence" } }
|
||||
{ $values { "seq" sequence } { "quot" { $quotation ( ... elt -- ... newelt ) } } { "newseq" "a new sequence" } }
|
||||
{ $description "Applies the quotation to each element of the sequence in order. The new elements are collected into a sequence of the same class as the input sequence." } ;
|
||||
|
||||
HELP: map-as
|
||||
{ $values { "seq" sequence } { "quot" { $quotation "( ... elt -- ... newelt )" } } { "exemplar" sequence } { "newseq" "a new sequence" } }
|
||||
{ $values { "seq" sequence } { "quot" { $quotation ( ... elt -- ... newelt ) } } { "exemplar" sequence } { "newseq" "a new sequence" } }
|
||||
{ $description "Applies the quotation to each element of the sequence in order. The new elements are collected into a sequence of the same class as " { $snippet "exemplar" } "." }
|
||||
{ $examples
|
||||
"The following example converts a string into an array of one-element strings:"
|
||||
|
@ -359,7 +359,7 @@ HELP: map-as
|
|||
|
||||
HELP: each-index
|
||||
{ $values
|
||||
{ "seq" sequence } { "quot" { $quotation "( ... elt index -- ... )" } } }
|
||||
{ "seq" sequence } { "quot" { $quotation ( ... elt index -- ... ) } } }
|
||||
{ $description "Calls the quotation with the element of the sequence and its index on the stack, with the index on the top of the stack." }
|
||||
{ $examples { $example "USING: arrays sequences prettyprint ;"
|
||||
"{ 10 20 30 } [ 2array . ] each-index"
|
||||
|
@ -368,7 +368,7 @@ HELP: each-index
|
|||
|
||||
HELP: map-index
|
||||
{ $values
|
||||
{ "seq" sequence } { "quot" { $quotation "( ... elt index -- ... newelt )" } } { "newseq" sequence } }
|
||||
{ "seq" sequence } { "quot" { $quotation ( ... elt index -- ... newelt ) } } { "newseq" sequence } }
|
||||
{ $description "Calls the quotation with the element of the sequence and its index on the stack, with the index on the top of the stack. Collects the outputs of the quotation and outputs them in a sequence of the same type as the input sequence." }
|
||||
{ $examples { $example "USING: arrays sequences prettyprint ;"
|
||||
"{ 10 20 30 } [ 2array ] map-index ."
|
||||
|
@ -376,13 +376,13 @@ HELP: map-index
|
|||
} } ;
|
||||
|
||||
HELP: change-nth
|
||||
{ $values { "i" "a non-negative integer" } { "seq" "a mutable sequence" } { "quot" { $quotation "( ..a elt -- ..b newelt )" } } }
|
||||
{ $values { "i" "a non-negative integer" } { "seq" "a mutable sequence" } { "quot" { $quotation ( ..a elt -- ..b newelt ) } } }
|
||||
{ $description "Applies the quotation to the " { $snippet "i" } "th element of the sequence, storing the result back into the sequence." }
|
||||
{ $errors "Throws an error if the sequence is immutable, if the index is out of bounds, or the sequence cannot hold elements of the type output by " { $snippet "quot" } "." }
|
||||
{ $side-effects "seq" } ;
|
||||
|
||||
HELP: map!
|
||||
{ $values { "seq" "a mutable sequence" } { "quot" { $quotation "( ... elt -- ... newelt )" } } }
|
||||
{ $values { "seq" "a mutable sequence" } { "quot" { $quotation ( ... elt -- ... newelt ) } } }
|
||||
{ $description "Applies the quotation to each element yielding a new element, storing the new elements back in the original sequence. Returns the original sequence." }
|
||||
{ $errors "Throws an error if the sequence is immutable, or the sequence cannot hold elements of the type output by " { $snippet "quot" } "." }
|
||||
{ $side-effects "seq" } ;
|
||||
|
@ -396,44 +396,44 @@ HELP: max-length
|
|||
{ $description "Outputs the maximum of the lengths of the two sequences." } ;
|
||||
|
||||
HELP: 2each
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( ... elt1 elt2 -- ... )" } } }
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation ( ... elt1 elt2 -- ... ) } } }
|
||||
{ $description "Applies the quotation to pairs of elements from " { $snippet "seq1" } " and " { $snippet "seq2" } "." } ;
|
||||
|
||||
HELP: 3each
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "seq3" sequence } { "quot" { $quotation "( ... elt1 elt2 elt3 -- ... )" } } }
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "seq3" sequence } { "quot" { $quotation ( ... elt1 elt2 elt3 -- ... ) } } }
|
||||
{ $description "Applies the quotation to triples of elements from " { $snippet "seq1" } ", " { $snippet "seq2" } " and " { $snippet "seq3" } "." } ;
|
||||
|
||||
HELP: 2reduce
|
||||
{ $values { "seq1" sequence }
|
||||
{ "seq2" sequence }
|
||||
{ "identity" object }
|
||||
{ "quot" { $quotation "( ... prev elt1 elt2 -- ... next )" } }
|
||||
{ "quot" { $quotation ( ... prev elt1 elt2 -- ... next ) } }
|
||||
{ "result" "the final result" } }
|
||||
{ $description "Combines successive pairs of elements from the two sequences using a ternary operation. The first input value at each iteration except the first one is the result of the previous iteration. The first input value at the first iteration is " { $snippet "identity" } "." } ;
|
||||
|
||||
HELP: 2map
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( ... elt1 elt2 -- ... newelt )" } } { "newseq" "a new sequence" } }
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation ( ... elt1 elt2 -- ... newelt ) } } { "newseq" "a new sequence" } }
|
||||
{ $description "Applies the quotation to each pair of elements in turn, yielding new elements which are collected into a new sequence having the same class as " { $snippet "seq1" } "." } ;
|
||||
|
||||
HELP: 3map
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "seq3" sequence } { "quot" { $quotation "( ... elt1 elt2 elt3 -- ... newelt )" } } { "newseq" "a new sequence" } }
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "seq3" sequence } { "quot" { $quotation ( ... elt1 elt2 elt3 -- ... newelt ) } } { "newseq" "a new sequence" } }
|
||||
{ $description "Applies the quotation to each triple of elements in turn, yielding new elements which are collected into a new sequence having the same class as " { $snippet "seq1" } "." } ;
|
||||
|
||||
HELP: 2map-as
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( ... elt1 elt2 -- ... newelt )" } } { "exemplar" sequence } { "newseq" "a new sequence" } }
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation ( ... elt1 elt2 -- ... newelt ) } } { "exemplar" sequence } { "newseq" "a new sequence" } }
|
||||
{ $description "Applies the quotation to each pair of elements in turn, yielding new elements which are collected into a new sequence having the same class as " { $snippet "exemplar" } "." } ;
|
||||
|
||||
HELP: 3map-as
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "seq3" sequence } { "quot" { $quotation "( ... elt1 elt2 elt3 -- ... newelt )" } } { "exemplar" sequence } { "newseq" "a new sequence" } }
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "seq3" sequence } { "quot" { $quotation ( ... elt1 elt2 elt3 -- ... newelt ) } } { "exemplar" sequence } { "newseq" "a new sequence" } }
|
||||
{ $description "Applies the quotation to each triple of elements in turn, yielding new elements which are collected into a new sequence having the same class as " { $snippet "exemplar" } "." } ;
|
||||
|
||||
HELP: 2all?
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( ... elt1 elt2 -- ... ? )" } } { "?" "a boolean" } }
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation ( ... elt1 elt2 -- ... ? ) } } { "?" "a boolean" } }
|
||||
{ $description "Tests the predicate pairwise against elements of " { $snippet "seq1" } " and " { $snippet "seq2" } "." } ;
|
||||
|
||||
HELP: find
|
||||
{ $values { "seq" sequence }
|
||||
{ "quot" { $quotation "( ... elt -- ... ? )" } }
|
||||
{ "quot" { $quotation ( ... elt -- ... ? ) } }
|
||||
{ "i" "the index of the first match, or " { $link f } }
|
||||
{ "elt" "the first matching element, or " { $link f } } }
|
||||
{ $description "A simpler variant of " { $link find-from } " where the starting index is 0." } ;
|
||||
|
@ -441,22 +441,22 @@ HELP: find
|
|||
HELP: find-from
|
||||
{ $values { "n" "a starting index" }
|
||||
{ "seq" sequence }
|
||||
{ "quot" { $quotation "( ... elt -- ... ? )" } }
|
||||
{ "quot" { $quotation ( ... elt -- ... ? ) } }
|
||||
{ "i" "the index of the first match, or " { $link f } }
|
||||
{ "elt" "the first matching element, or " { $link f } } }
|
||||
{ $description "Applies the quotation to each element of the sequence in turn, until it outputs a true value or the end of the sequence is reached. If the quotation yields a true value for some sequence element, the word outputs the element index and the element itself. Otherwise, the word outputs an index of " { $link f } " and " { $link f } " as the element." } ;
|
||||
|
||||
HELP: find-last
|
||||
{ $values { "seq" sequence } { "quot" { $quotation "( ... elt -- ... ? )" } } { "i" "the index of the first match, or f" } { "elt" "the first matching element, or " { $link f } } }
|
||||
{ $values { "seq" sequence } { "quot" { $quotation ( ... elt -- ... ? ) } } { "i" "the index of the first match, or f" } { "elt" "the first matching element, or " { $link f } } }
|
||||
{ $description "A simpler variant of " { $link find-last-from } " where the starting index is one less than the length of the sequence." } ;
|
||||
|
||||
HELP: find-last-from
|
||||
{ $values { "n" "a starting index" } { "seq" sequence } { "quot" { $quotation "( ... elt -- ... ? )" } } { "i" "the index of the first match, or f" } { "elt" "the first matching element, or " { $link f } } }
|
||||
{ $values { "n" "a starting index" } { "seq" sequence } { "quot" { $quotation ( ... elt -- ... ? ) } } { "i" "the index of the first match, or f" } { "elt" "the first matching element, or " { $link f } } }
|
||||
{ $description "Applies the quotation to each element of the sequence in reverse order, until it outputs a true value or the start of the sequence is reached. If the quotation yields a true value for some sequence element, the word outputs the element index and the element itself. Otherwise, the word outputs an index of " { $link f } " and " { $link f } " as the element." } ;
|
||||
|
||||
HELP: find-index
|
||||
{ $values { "seq" sequence }
|
||||
{ "quot" { $quotation "( ... elt i -- ... ? )" } }
|
||||
{ "quot" { $quotation ( ... elt i -- ... ? ) } }
|
||||
{ "i" "the index of the first match, or " { $link f } }
|
||||
{ "elt" "the first matching element, or " { $link f } } }
|
||||
{ $description "A varient of " { $link find } " where the quotation takes both an element and its index." } ;
|
||||
|
@ -464,43 +464,43 @@ HELP: find-index
|
|||
HELP: find-index-from
|
||||
{ $values { "n" "a starting index" }
|
||||
{ "seq" sequence }
|
||||
{ "quot" { $quotation "( ... elt i -- ... ? )" } }
|
||||
{ "quot" { $quotation ( ... elt i -- ... ? ) } }
|
||||
{ "i" "the index of the first match, or " { $link f } }
|
||||
{ "elt" "the first matching element, or " { $link f } } }
|
||||
{ $description "A varient of " { $link find-from } " where the quotation takes both an element and its index." } ;
|
||||
|
||||
HELP: map-find
|
||||
{ $values { "seq" sequence } { "quot" { $quotation "( ... elt -- ... result/f )" } } { "result" "the first non-false result of the quotation" } { "elt" "the first matching element, or " { $link f } } }
|
||||
{ $values { "seq" sequence } { "quot" { $quotation ( ... elt -- ... result/f ) } } { "result" "the first non-false result of the quotation" } { "elt" "the first matching element, or " { $link f } } }
|
||||
{ $description "Applies the quotation to each element of the sequence, until the quotation outputs a true value. If the quotation ever yields a result which is not " { $link f } ", then the value is output, along with the element of the sequence which yielded this." } ;
|
||||
|
||||
HELP: any?
|
||||
{ $values { "seq" sequence } { "quot" { $quotation "( ... elt -- ... ? )" } } { "?" "a boolean" } }
|
||||
{ $values { "seq" sequence } { "quot" { $quotation ( ... elt -- ... ? ) } } { "?" "a boolean" } }
|
||||
{ $description "Tests if the sequence contains an element satisfying the predicate, by applying the predicate to each element in turn until a true value is found. If the sequence is empty or if the end of the sequence is reached, outputs " { $link f } "." } ;
|
||||
|
||||
HELP: all?
|
||||
{ $values { "seq" sequence } { "quot" { $quotation "( ... elt -- ... ? )" } } { "?" "a boolean" } }
|
||||
{ $values { "seq" sequence } { "quot" { $quotation ( ... 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 } "." } ;
|
||||
|
||||
HELP: push-if
|
||||
{ $values { "elt" object } { "quot" { $quotation "( ..a elt -- ..b ? )" } } { "accum" "a resizable mutable sequence" } }
|
||||
{ $values { "elt" object } { "quot" { $quotation ( ..a elt -- ..b ? ) } } { "accum" "a resizable mutable sequence" } }
|
||||
{ $description "Adds the element at the end of the sequence if the quotation yields a true value." }
|
||||
{ $notes "This word is a factor of " { $link filter } "." } ;
|
||||
|
||||
HELP: filter
|
||||
{ $values { "seq" sequence } { "quot" { $quotation "( ... elt -- ... ? )" } } { "subseq" "a new sequence" } }
|
||||
{ $values { "seq" sequence } { "quot" { $quotation ( ... elt -- ... ? ) } } { "subseq" "a new sequence" } }
|
||||
{ $description "Applies the quotation to each element in turn, and outputs a new sequence containing the elements of the original sequence for which the quotation output a true value." } ;
|
||||
|
||||
HELP: filter-as
|
||||
{ $values { "seq" sequence } { "quot" { $quotation "( ... elt -- ... ? )" } } { "exemplar" sequence } { "subseq" "a new sequence" } }
|
||||
{ $values { "seq" sequence } { "quot" { $quotation ( ... elt -- ... ? ) } } { "exemplar" sequence } { "subseq" "a new sequence" } }
|
||||
{ $description "Applies the quotation to each element in turn, and outputs a new sequence of the same type as " { $snippet "exemplar" } " containing the elements of the original sequence for which the quotation output a true value." } ;
|
||||
|
||||
HELP: filter!
|
||||
{ $values { "seq" "a resizable mutable sequence" } { "quot" { $quotation "( ... elt -- ... ? )" } } }
|
||||
{ $values { "seq" "a resizable mutable sequence" } { "quot" { $quotation ( ... elt -- ... ? ) } } }
|
||||
{ $description "Applies the quotation to each element in turn, and removes elements for which the quotation outputs a false value." }
|
||||
{ $side-effects "seq" } ;
|
||||
|
||||
HELP: interleave
|
||||
{ $values { "seq" sequence } { "between" "a quotation" } { "quot" { $quotation "( ... elt -- ... )" } } }
|
||||
{ $values { "seq" sequence } { "between" "a quotation" } { "quot" { $quotation ( ... elt -- ... ) } } }
|
||||
{ $description "Applies " { $snippet "quot" } " to each element in turn, also invoking " { $snippet "between" } " in-between each pair of elements." }
|
||||
{ $examples { $example "USING: io sequences ;" "{ \"a\" \"b\" \"c\" } [ \"X\" write ] [ write ] interleave" "aXbXc" } } ;
|
||||
|
||||
|
@ -681,7 +681,7 @@ HELP: reverse!
|
|||
{ $side-effects "seq" } ;
|
||||
|
||||
HELP: padding
|
||||
{ $values { "seq" sequence } { "n" "a non-negative integer" } { "elt" object } { "quot" { $quotation "( ... seq1 seq2 -- ... newseq )" } } { "newseq" "a new sequence" } }
|
||||
{ $values { "seq" sequence } { "n" "a non-negative integer" } { "elt" object } { "quot" { $quotation ( ... seq1 seq2 -- ... newseq ) } } { "newseq" "a new sequence" } }
|
||||
{ $description "Outputs a new string sequence of " { $snippet "elt" } " repeated, that when appended to " { $snippet "seq" } ", yields a sequence of length " { $snippet "n" } ". If the length of " { $snippet "seq" } " is greater than " { $snippet "n" } ", this word outputs an empty sequence." } ;
|
||||
|
||||
HELP: pad-head
|
||||
|
@ -1041,7 +1041,7 @@ HELP: supremum
|
|||
{ min max supremum infimum } related-words
|
||||
|
||||
HELP: produce
|
||||
{ $values { "pred" { $quotation "( ..a -- ..b ? )" } } { "quot" { $quotation "( ..b -- ..a obj )" } } { "seq" "a sequence" } }
|
||||
{ $values { "pred" { $quotation ( ..a -- ..b ? ) } } { "quot" { $quotation ( ..b -- ..a obj ) } } { "seq" "a sequence" } }
|
||||
{ $description "Calls " { $snippet "pred" } " repeatedly. If the predicate yields " { $link f } ", stops, otherwise, calls " { $snippet "quot" } " to yield a value. Values are accumulated and returned in a sequence at the end." }
|
||||
{ $examples
|
||||
"The following example divides a number by two until we reach zero, and accumulates intermediate results:"
|
||||
|
@ -1051,7 +1051,7 @@ HELP: produce
|
|||
} ;
|
||||
|
||||
HELP: produce-as
|
||||
{ $values { "pred" { $quotation "( ..a -- ..b ? )" } } { "quot" { $quotation "( ..b -- ..a obj )" } } { "exemplar" sequence } { "seq" "a sequence" } }
|
||||
{ $values { "pred" { $quotation ( ..a -- ..b ? ) } } { "quot" { $quotation ( ..b -- ..a obj ) } } { "exemplar" sequence } { "seq" "a sequence" } }
|
||||
{ $description "Calls " { $snippet "pred" } " repeatedly. If the predicate yields " { $link f } ", stops, otherwise, calls " { $snippet "quot" } " to yield a value. Values are accumulated and returned in a sequence of type " { $snippet "exemplar" } " at the end." }
|
||||
{ $examples "See " { $link produce } " for examples." } ;
|
||||
|
||||
|
@ -1079,8 +1079,8 @@ HELP: count
|
|||
|
||||
HELP: selector
|
||||
{ $values
|
||||
{ "quot" { $quotation "( ... elt -- ... ? )" } }
|
||||
{ "selector" { $quotation "( ... elt -- ... )" } } { "accum" vector } }
|
||||
{ "quot" { $quotation ( ... elt -- ... ? ) } }
|
||||
{ "selector" { $quotation ( ... elt -- ... ) } } { "accum" vector } }
|
||||
{ $description "Creates a new vector to accumulate the values which return true for a predicate. Returns a new quotation which accepts an object to be tested and stored in the collector if the test yields true. The collector is left on the stack for convenience." }
|
||||
{ $examples
|
||||
{ $example "! Find all the even numbers:" "USING: prettyprint sequences math kernel ;"
|
||||
|
@ -1238,7 +1238,7 @@ HELP: set-fourth
|
|||
|
||||
HELP: replicate
|
||||
{ $values
|
||||
{ "len" integer } { "quot" { $quotation "( ... -- ... newelt )" } }
|
||||
{ "len" integer } { "quot" { $quotation ( ... -- ... newelt ) } }
|
||||
{ "newseq" sequence } }
|
||||
{ $description "Calls the quotation " { $snippet "len" } " times, collecting results into a new array." }
|
||||
{ $examples
|
||||
|
@ -1250,7 +1250,7 @@ HELP: replicate
|
|||
|
||||
HELP: replicate-as
|
||||
{ $values
|
||||
{ "len" integer } { "quot" { $quotation "( ... -- ... newelt )" } } { "exemplar" sequence }
|
||||
{ "len" integer } { "quot" { $quotation ( ... -- ... newelt ) } } { "exemplar" sequence }
|
||||
{ "newseq" sequence } }
|
||||
{ $description "Calls the quotation " { $snippet "len" } " times, collecting results into a new sequence of the same type as the exemplar sequence." }
|
||||
{ $examples
|
||||
|
@ -1288,7 +1288,7 @@ HELP: virtual@
|
|||
|
||||
HELP: 2map-reduce
|
||||
{ $values
|
||||
{ "seq1" sequence } { "seq2" sequence } { "map-quot" { $quotation "( ..a elt1 elt2 -- ..b intermediate )" } } { "reduce-quot" { $quotation "( ..b prev intermediate -- ..a next )" } }
|
||||
{ "seq1" sequence } { "seq2" sequence } { "map-quot" { $quotation ( ..a elt1 elt2 -- ..b intermediate ) } } { "reduce-quot" { $quotation ( ..b prev intermediate -- ..a next ) } }
|
||||
{ "result" object } }
|
||||
{ $description "Calls " { $snippet "map-quot" } " on each pair of elements from " { $snippet "seq1" } " and " { $snippet "seq2" } " and combines the results using " { $snippet "reduce-quot" } " in the same manner as " { $link reduce } ", except that there is no identity element, and the sequence must have a length of at least 1." }
|
||||
{ $errors "Throws an error if the sequence is empty." }
|
||||
|
@ -1315,7 +1315,7 @@ HELP: collector
|
|||
|
||||
HELP: binary-reduce
|
||||
{ $values
|
||||
{ "seq" sequence } { "start" integer } { "quot" { $quotation "( elt1 elt2 -- newelt )" } }
|
||||
{ "seq" sequence } { "start" integer } { "quot" { $quotation ( elt1 elt2 -- newelt ) } }
|
||||
{ "value" object } }
|
||||
{ $description "Like " { $link reduce } ", but splits the sequence in half recursively until each sequence is small enough, and calls the quotation on these smaller sequences. If the quotation computes values that depend on the size of their input, such as bignum arithmetic, then this algorithm can be more efficient than using " { $link reduce } "." }
|
||||
{ $examples "Computing factorial:"
|
||||
|
@ -1326,7 +1326,7 @@ HELP: binary-reduce
|
|||
|
||||
HELP: follow
|
||||
{ $values
|
||||
{ "obj" object } { "quot" { $quotation "( ... prev -- ... result/f )" } }
|
||||
{ "obj" object } { "quot" { $quotation ( ... prev -- ... result/f ) } }
|
||||
{ "seq" sequence } }
|
||||
{ $description "Outputs a sequence containing the input object and all of the objects generated by successively feeding the result of the quotation called on the input object to the quotation recursively. Objects yielded by the quotation are added to the output sequence until the quotation yields " { $link f } ", at which point the recursion terminates." }
|
||||
{ $examples "Get random numbers until zero is reached:"
|
||||
|
@ -1368,7 +1368,7 @@ HELP: insert-nth
|
|||
|
||||
HELP: map-reduce
|
||||
{ $values
|
||||
{ "seq" sequence } { "map-quot" { $quotation "( ..a elt -- ..b intermediate )" } } { "reduce-quot" { $quotation "( ..b prev intermediate -- ..a next )" } }
|
||||
{ "seq" sequence } { "map-quot" { $quotation ( ..a elt -- ..b intermediate ) } } { "reduce-quot" { $quotation ( ..b prev intermediate -- ..a next ) } }
|
||||
{ "result" object } }
|
||||
{ $description "Calls " { $snippet "map-quot" } " on each element and combines the results using " { $snippet "reduce-quot" } " in the same manner as " { $link reduce } ", except that there is no identity element, and the sequence must have a length of at least 1." }
|
||||
{ $errors "Throws an error if the sequence is empty." }
|
||||
|
@ -1443,11 +1443,11 @@ HELP: assert-sequence=
|
|||
} ;
|
||||
|
||||
HELP: cartesian-each
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( ... elt1 elt2 -- ... )" } } }
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation ( ... elt1 elt2 -- ... ) } } }
|
||||
{ $description "Applies the quotation to every possible pairing of elements from the two sequences." } ;
|
||||
|
||||
HELP: cartesian-map
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( ... elt1 elt2 -- ... newelt )" } } { "newseq" "a new sequence of sequences" } }
|
||||
{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation ( ... elt1 elt2 -- ... newelt ) } } { "newseq" "a new sequence of sequences" } }
|
||||
{ $description "Applies the quotation to every possible pairing of elements from the two sequences, collecting results into a new sequence of sequences." } ;
|
||||
|
||||
HELP: cartesian-product
|
||||
|
|
|
@ -23,16 +23,16 @@ $nl
|
|||
ABOUT: "sequences-sorting"
|
||||
|
||||
HELP: sort
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation "( obj1 obj2 -- <=> )" } } { "sortedseq" "a new sorted sequence" } }
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation ( obj1 obj2 -- <=> ) } } { "sortedseq" "a new sorted sequence" } }
|
||||
{ $description "Sorts the elements of " { $snippet "seq" } " into a new array using a stable sort." }
|
||||
{ $notes "The algorithm used is the merge sort." } ;
|
||||
|
||||
HELP: sort-with
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation "( elt -- key )" } } { "sortedseq" "a new sorted sequence" } }
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation ( elt -- key ) } } { "sortedseq" "a new sorted sequence" } }
|
||||
{ $description "Sorts the elements of " { $snippet "seq" } " by applying " { $link compare } " with " { $snippet "quot" } " to each pair of elements in the sequence." } ;
|
||||
|
||||
HELP: inv-sort-with
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation "( elt -- key )" } } { "sortedseq" "a new sorted sequence" } }
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation ( elt -- key ) } } { "sortedseq" "a new sorted sequence" } }
|
||||
{ $description "Sorts the elements of " { $snippet "seq" } " by applying " { $link compare } " with " { $snippet "quot" } " to each pair of elements in the sequence and inverting the results." } ;
|
||||
|
||||
HELP: sort-keys
|
||||
|
|
|
@ -34,11 +34,11 @@ HELP: split1-slice
|
|||
{ $description "Splits " { $snippet "seq" } " at the first occurrence of " { $snippet "subseq" } ", and outputs the pieces before and after the split as slices. If " { $snippet "subseq" } " does not occur in " { $snippet "seq" } ", then " { $snippet "before" } " is just " { $snippet "seq" } " and " { $snippet "after" } " is " { $link f } "." } ;
|
||||
|
||||
HELP: split1-when
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation "( ... elt -- ... ? )" } } { "before" "a new sequence" } { "after" "a new sequence" } }
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation ( ... elt -- ... ? ) } } { "before" "a new sequence" } { "after" "a new sequence" } }
|
||||
{ $description "Splits " { $snippet "seq" } " at the first occurrence of an element for which " { $snippet "quot" } " gives a true output and outputs the pieces before and after the split." } ;
|
||||
|
||||
HELP: split1-when-slice
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation "( ... elt -- ... ? )" } } { "before-slice" slice } { "after-slice" slice } }
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation ( ... elt -- ... ? ) } } { "before-slice" slice } { "after-slice" slice } }
|
||||
{ $description "Splits " { $snippet "seq" } " at the first occurrence of an element for which " { $snippet "quot" } " gives a true output and outputs the pieces before and after the split as slices. If " { $snippet "subseq" } " does not occur in " { $snippet "seq" } ", then " { $snippet "before" } " is just " { $snippet "seq" } " and " { $snippet "after" } " is " { $link f } "." } ;
|
||||
|
||||
HELP: split1-last
|
||||
|
@ -52,12 +52,12 @@ HELP: split1-last-slice
|
|||
{ split1 split1-slice split1-last split1-last-slice } related-words
|
||||
|
||||
HELP: split-when
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation "( ... elt -- ... ? )" } } { "pieces" "a new array" } }
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation ( ... elt -- ... ? ) } } { "pieces" "a new array" } }
|
||||
{ $description "Splits " { $snippet "seq" } " at each occurrence of an element for which " { $snippet "quot" } " gives a true output and outputs an array of pieces. The pieces do not include the elements along which the sequence was split." }
|
||||
{ $examples { $example "USING: ascii kernel prettyprint splitting ;" "\"hello,world-how.are:you\" [ letter? not ] split-when ." "{ \"hello\" \"world\" \"how\" \"are\" \"you\" }" } } ;
|
||||
|
||||
HELP: split-when-slice
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation "( ... elt -- ... ? )" } } { "pieces" "a new array" } }
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation ( ... elt -- ... ? ) } } { "pieces" "a new array" } }
|
||||
{ $description "Splits " { $snippet "seq" } " at each occurrence of an element for which " { $snippet "quot" } " gives a true output and outputs an array of pieces as slices. The pieces do not include the elements along which the sequence was split." } ;
|
||||
|
||||
HELP: split
|
||||
|
|
|
@ -80,7 +80,7 @@ HELP: forget-vocab
|
|||
{ $notes "This word must be called from inside " { $link with-compilation-unit } "." } ;
|
||||
|
||||
HELP: require-hook
|
||||
{ $var-description { $quotation "( name -- )" } " which loads a vocabulary. This quotation is called by " { $link require } ". The default value should not need to be changed; this functionality is implemented via a hook stored in a variable to break a circular dependency which would otherwise exist from " { $vocab-link "vocabs" } " to " { $vocab-link "vocabs.loader" } " to " { $vocab-link "parser" } " back to " { $vocab-link "vocabs" } "." } ;
|
||||
{ $var-description { $quotation ( name -- ) } " which loads a vocabulary. This quotation is called by " { $link require } ". The default value should not need to be changed; this functionality is implemented via a hook stored in a variable to break a circular dependency which would otherwise exist from " { $vocab-link "vocabs" } " to " { $vocab-link "vocabs.loader" } " to " { $vocab-link "parser" } " back to " { $vocab-link "vocabs" } "." } ;
|
||||
|
||||
HELP: require
|
||||
{ $values { "object" "a vocabulary specifier" } }
|
||||
|
|
|
@ -30,7 +30,7 @@ HELP: amb-execute
|
|||
|
||||
HELP: if-amb
|
||||
{ $values
|
||||
{ "true" { $quotation "( -- ? )" } }
|
||||
{ "true" { $quotation ( -- ? ) } }
|
||||
{ "false" quotation }
|
||||
{ "?" "a boolean" }
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ HELP: if-amb
|
|||
|
||||
HELP: amb-all
|
||||
{ $values
|
||||
{ "quot" { $quotation "( -- )" } }
|
||||
{ "quot" { $quotation ( -- ) } }
|
||||
}
|
||||
{ $description "Execute all the alternatives in the quotation by calling " { $link fail } " repeatedly at the end." }
|
||||
{ $see-also bag-of fail }
|
||||
|
@ -46,7 +46,7 @@ HELP: amb-all
|
|||
|
||||
HELP: bag-of
|
||||
{ $values
|
||||
{ "quot" { $quotation "( -- result )" } }
|
||||
{ "quot" { $quotation ( -- result ) } }
|
||||
{ "seq" sequence }
|
||||
}
|
||||
{ $description "Execute all the alternatives in the quotation and collect the results." }
|
||||
|
|
|
@ -3,7 +3,7 @@ USING: help.markup help.syntax kernel ;
|
|||
IN: coroutines
|
||||
|
||||
HELP: cocreate
|
||||
{ $values { "quot" { $quotation "( value -- )" } } { "co" coroutine } }
|
||||
{ $values { "quot" { $quotation ( value -- ) } } { "co" coroutine } }
|
||||
{ $description "Create a new coroutine which will execute the quotation when resumed. The quotation will have an initial value (received from " { $link coresume } ") on the stack when first resumed.\n\nCoroutines should never terminate normally by \"falling off\" the end of the quotation; instead, they should call " { $link coterminate } "." }
|
||||
;
|
||||
|
||||
|
|
|
@ -207,13 +207,13 @@ HELP: vertex-buffer
|
|||
|
||||
HELP: with-mapped-buffer
|
||||
{ $values
|
||||
{ "buffer" buffer } { "access" buffer-access-mode } { "quot" { $quotation "( ..a alien -- ..b )" } }
|
||||
{ "buffer" buffer } { "access" buffer-access-mode } { "quot" { $quotation ( ..a alien -- ..b ) } }
|
||||
}
|
||||
{ $description "Maps " { $snippet "buffer" } " into CPU address space with " { $snippet "access" } " for the dynamic extent of " { $snippet "quot" } ". " { $snippet "quot" } " is called with a pointer to the mapped memory on top of the stack." } ;
|
||||
|
||||
HELP: with-mapped-buffer-array
|
||||
{ $values
|
||||
{ "buffer" buffer } { "access" buffer-access-mode } { "c-type" "a C type" } { "quot" { $quotation "( ..a array -- ..b )" } }
|
||||
{ "buffer" buffer } { "access" buffer-access-mode } { "c-type" "a C type" } { "quot" { $quotation ( ..a array -- ..b ) } }
|
||||
}
|
||||
{ $description "Maps " { $snippet "buffer" } " into CPU address space with " { $snippet "access" } " for the dynamic extent of " { $snippet "quot" } ". " { $snippet "quot" } " is called with the pointer to the mapped memory wrapped in a specialized array of " { $snippet "c-type" } "." }
|
||||
{ $notes "The appropriate specialized array vocabulary must be loaded; otherwise, an error will be thrown. See the " { $vocab-link "specialized-arrays" } " vocabulary for details on the underlying sequence type constructed." } ;
|
||||
|
|
|
@ -3,7 +3,7 @@ USING: help.markup help.syntax sequences splitting strings ;
|
|||
IN: grouping.extras
|
||||
|
||||
HELP: group-by
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation "( elt -- key )" } } { "groups" "a new assoc" } }
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation ( elt -- key ) } } { "groups" "a new assoc" } }
|
||||
{ $description "Groups the elements by the key received by applying quot to each element in the sequence." }
|
||||
{ $examples
|
||||
{ $example
|
||||
|
|
|
@ -7,9 +7,9 @@ HELP: html-class?
|
|||
{ $description "t if the tag has the given class." } ;
|
||||
|
||||
HELP: stack-find
|
||||
{ $values { "seq" sequence } { "quot" { $quotation "( elt -- 1/0/-1 )" } } { "i/f" "an index or " { $link f } } }
|
||||
{ $values { "seq" sequence } { "quot" { $quotation ( elt -- 1/0/-1 ) } } { "i/f" "an index or " { $link f } } }
|
||||
{ $description "Takes a sequence and a quotation expected to return -1 if the element decrements the stack, 0 if it doesnt affect it and 1 if it increments it. Then finds the first element where the stack is empty." } ;
|
||||
|
||||
HELP: tag-classifier
|
||||
{ $values { "string" string } { "quot" { $quotation "( elt -- 1/0/-1 )" } } }
|
||||
{ $values { "string" string } { "quot" { $quotation ( elt -- 1/0/-1 ) } } }
|
||||
{ $description "Builds a function that classifies tag tuples. Returns 1 if the tag is an opening tag with the given name, -1 if it is a closing tag and 0 otherwise." } ;
|
||||
|
|
|
@ -2,12 +2,12 @@ IN: partial-continuations
|
|||
USING: help.markup help.syntax kernel ;
|
||||
|
||||
HELP: breset
|
||||
{ $values { "quot" { $quotation "( r -- v )" } } }
|
||||
{ $values { "quot" { $quotation ( r -- v ) } } }
|
||||
{ $description "Marks the boundary of the partial continuation. The quotation has stack effect " { $snippet "( r -- v )" } ", where " { $snippet "r" } " identifies the " { $link breset } " in scope and should be passed to "{ $link bshift } " to mark the boundary of the continuation." }
|
||||
{ $notes "It is important to note that even if the quotation discards items on the stack, the stack will be restored to the way it was before it is called (which is true of continuation usage in general)." } ;
|
||||
|
||||
HELP: bshift
|
||||
{ $values { "r" "the " { $link breset } " in scope" } { "quot" { $quotation "( pcc -- v )" } } }
|
||||
{ $values { "r" "the " { $link breset } " in scope" } { "quot" { $quotation ( pcc -- v ) } } }
|
||||
{ $description "Calls the quotation with the partial continuation on the stack. The quotation should have stack effect " { $snippet "( pcc -- v )" } ". The partial continuation can be called with " { $link call } " and has stack effect " { $snippet "( a -- b )" } "." }
|
||||
{ $notes "It is important to note that even if the quotation discards items on the stack, the stack will be restored to the way it was before it is called (which is true of continuation usage in general)." } ;
|
||||
|
||||
|
|
|
@ -42,9 +42,9 @@ HELP: neighbours
|
|||
|
||||
HELP: <astar>
|
||||
{ $values
|
||||
{ "neighbours" { $quotation "( node -- seq )" } }
|
||||
{ "cost" { $quotation "( from to -- cost )" } }
|
||||
{ "heuristic" { $quotation "( pos target -- cost )" } }
|
||||
{ "neighbours" { $quotation ( node -- seq ) } }
|
||||
{ "cost" { $quotation ( from to -- cost ) } }
|
||||
{ "heuristic" { $quotation ( pos target -- cost ) } }
|
||||
{ "astar" astar }
|
||||
}
|
||||
{ $description "Build an astar object from the given quotations. The "
|
||||
|
|
|
@ -14,11 +14,11 @@ HELP: readline
|
|||
|
||||
HELP: set-completion
|
||||
{ $values
|
||||
{ "quot" { $quotation "( str n -- str )" } }
|
||||
{ "quot" { $quotation ( str n -- str ) } }
|
||||
}
|
||||
{ $description "Set the given quotation as the completion hook for readline. The quotation is called with the string to complete and the index in the completion list to return. When all completions have been returned, returning " { $snippet "f" } " terminates the loop." }
|
||||
{ $examples
|
||||
{ $example "USING: readline sequences combinators kernel ;"
|
||||
{ $unchecked-example "USING: readline sequences combinators kernel ;"
|
||||
"[ nip [ \"keep\" \"dip\" ] ?nth ] set-completion"
|
||||
""
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ USING: help.markup help.syntax sequences splitting strings ;
|
|||
IN: splitting.extras
|
||||
|
||||
HELP: split*-when
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation "( ... elt -- ... ? )" } } { "pieces" "a new array" } }
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation ( ... elt -- ... ? ) } } { "pieces" "a new array" } }
|
||||
{ $description "A variant of " { $link split-when } " that includes the elements along which the sequence was split." }
|
||||
{ $examples { $example "USING: ascii kernel prettyprint splitting.extras ;" "\"hello,world-how.are:you\" [ letter? not ] split*-when ." "{ \"hello\" \",\" \"world\" \"-\" \"how\" \".\" \"are\" \":\" \"you\" }" } } ;
|
||||
|
||||
|
@ -12,5 +12,5 @@ HELP: split*
|
|||
{ $examples { $example "USING: prettyprint splitting.extras ;" "\"hello world-how are you?\" \" -\" split* ." "{ \"hello\" \" \" \"world\" \"-\" \"how\" \" \" \"are\" \" \" \"you?\" }" } } ;
|
||||
|
||||
HELP: split-find
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation "( seq -- i )" } } { "pieces" "a new array" } }
|
||||
{ $values { "seq" "a sequence" } { "quot" { $quotation ( seq -- i ) } } { "pieces" "a new array" } }
|
||||
{ $description "Splits a sequence into slices using the provided quotation to find split points." } ;
|
||||
|
|
|
@ -14,7 +14,7 @@ HELP: list
|
|||
} ;
|
||||
|
||||
HELP: <list>
|
||||
{ $values { "hook" { $quotation "( list -- )" } } { "presenter" { $quotation "( object -- label )" } } { "model" model } { "gadget" list } }
|
||||
{ $values { "hook" { $quotation ( list -- ) } } { "presenter" { $quotation ( object -- label ) } } { "model" model } { "gadget" list } }
|
||||
{ $description "Creates a new " { $link list } "."
|
||||
$nl
|
||||
"The model value must be a sequence. The list displays presentations of elements with labels obtained by applying the " { $snippet "presenter" } " quotation to each object. The " { $snippet "hook" } " quotation is called when a presentation is selected." } ;
|
||||
|
|
Loading…
Reference in New Issue