]> gitweb.factorcode.org Git - factor.git/blob - basis/sequences/deep/deep-docs.factor
4d0b2e3699619ea5eeee2e2cdb5e821bccbf3a37
[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 -- ... elt' )" } } { "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-as
15 { $values { "obj" object } { "quot" { $quotation "( ... elt -- ... ? )" } } { "exemplar" sequence } { "seq" sequence } }
16 { $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." } ;
17
18 HELP: deep-filter
19 { $values { "obj" object } { "quot" { $quotation "( ... elt -- ... ? )" } } { "seq" sequence } }
20 { $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." }
21 { $see-also filter } ;
22
23 HELP: deep-find
24 { $values { "obj" object } { "quot" { $quotation "( ... elt -- ... ? )" } } { "elt" "an element" } }
25 { $description "Gets the first sub-node of the object, in preorder, which satisfies the quotation. If nothing satisfies it, it returns " { $link f } "." }
26 { $see-also find } ;
27
28 HELP: deep-any?
29 { $values { "obj" object } { "quot" { $quotation "( ... elt -- ... ? )" } } { "?" "a boolean" } }
30 { $description "Tests whether the given object or any subnode satisfies the given quotation." }
31 { $see-also any? } ;
32
33 HELP: flatten-as
34 { $values { "obj" object } { "exemplar" sequence } { "seq" sequence } }
35 { $description "Creates a sequence (of the same type as " { $snippet "exemplar" } ") of all of the leaf nodes (non-sequence nodes, but including strings and numbers) in the object." } ;
36
37 HELP: flatten
38 { $values { "obj" object } { "seq" sequence } }
39 { $description "Creates a sequence of all of the leaf nodes (non-sequence nodes, but including strings and numbers) in the object." } ;
40
41 HELP: deep-map!
42 { $values { "obj" object } { "quot" { $quotation "( ... elt -- ... elt' )" } } }
43 { $description "Modifies each sub-node of an object in place, in preorder, and returns that object." }
44 { $see-also map! } ;
45
46 ARTICLE: "sequences.deep" "Deep sequence combinators"
47 "The combinators in the " { $vocab-link "sequences.deep" } " vocabulary are variants of standard sequence combinators which traverse nested subsequences."
48 { $subsections
49     deep-each
50     deep-map
51     deep-filter
52     deep-find
53     deep-any?
54     deep-map!
55 }
56 "A utility word to collapse nested subsequences:"
57 { $subsections flatten } ;
58
59 ABOUT: "sequences.deep"