]> gitweb.factorcode.org Git - factor.git/blob - basis/sequences/deep/deep-docs.factor
e8b9ddea6d4bb19aa1de2b368e9ebb3140d48da3
[factor.git] / basis / sequences / deep / deep-docs.factor
1 USING: help.syntax help.markup kernel sequences ;
2 IN: sequences.deep
3
4 HELP: deep-each
5 { $values { "obj" object } { "quot" { $quotation "( elt -- )" } } }
6 { $description "Execute a quotation on each nested element of an object and its children, in preorder." }
7 { $see-also each } ;
8
9 HELP: deep-map
10 { $values { "obj" object } { "quot" { $quotation "( elt -- newelt )" } } { "newobj" "the mapped object" } }
11 { $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." }
12 { $see-also map }  ;
13
14 HELP: deep-filter
15 { $values { "obj" object } { "quot" { $quotation "( elt -- ? )" } } { "seq" "a sequence" } }
16 { $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." }
17 { $see-also filter }  ;
18
19 HELP: deep-find
20 { $values { "obj" object } { "quot" { $quotation "( elt -- ? )" } } { "elt" "an element" } }
21 { $description "Gets the first sub-node of the object, in preorder, which satisfies the quotation. If nothing satisifies it, it returns " { $link f } "." }
22 { $see-also find }  ;
23
24 HELP: deep-any?
25 { $values { "obj" object } { "quot" { $quotation "( elt -- ? )" } } { "?" "a boolean" } }
26 { $description "Tests whether the given object or any subnode satisfies the given quotation." }
27 { $see-also any? } ;
28
29 HELP: flatten
30 { $values { "obj" object } { "seq" "a sequence" } }
31 { $description "Creates a sequence of all of the leaf nodes (non-sequence nodes, but including strings and numbers) in the object." } ;
32
33 HELP: deep-map!
34 { $values { "obj" object } { "quot" { $quotation "( elt -- newelt )" } } { "obj" object } }
35 { $description "Modifies each sub-node of an object in place, in preorder, and returns that object." }
36 { $see-also map! } ;
37
38 ARTICLE: "sequences.deep" "Deep sequence combinators"
39 "The combinators in the " { $vocab-link "sequences.deep" } " vocabulary are variants of standard sequence combinators which traverse nested subsequences."
40 { $subsections
41     deep-each
42     deep-map
43     deep-filter
44     deep-find
45     deep-any?
46     deep-map!
47 }
48 "A utility word to collapse nested subsequences:"
49 { $subsections flatten } ;
50
51 ABOUT: "sequences.deep"