1 ! Copyright (C) 2009 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax kernel quotations classes sequences
5 IN: splitting.monotonic
9 { "seq" sequence } { "quot" quotation } { "class" class }
10 { "slices" "a sequence of slices" }
12 { $description "Monotonically splits a sequence into slices of the type " { $snippet "class" } "." }
15 "USING: splitting.monotonic math prettyprint ;"
16 "{ 1 2 3 2 3 4 } [ < ] upward-slice monotonic-slice ."
21 { seq { 1 2 3 2 3 4 } }
26 { seq { 1 2 3 2 3 4 } }
34 { "seq" sequence } { "quot" quotation }
35 { "newseq" "a sequence of sequences" }
37 { $description "Compares pairs of elements in a sequence and collects elements into sequences while they satisfy the predicate. Once the predicate fails, a new sequence is started, and all sequences are returned in a single sequence." }
40 "USING: splitting.monotonic math prettyprint ;"
41 "{ 1 2 3 2 3 4 } [ < ] monotonic-split ."
42 "{ V{ 1 2 3 } V{ 2 3 4 } }"
49 { "slices" "a sequence of downward-slices" }
51 { $description "Returns an array of monotonically decreasing slices of type " { $link downward-slice } ". Slices of one element are discarded." } ;
56 { "slices" "a sequence of stable-slices" }
58 { $description "Returns an array of monotonically decreasing slices of type " { $link downward-slice } ". Slices of one element are discarded." } ;
63 { "slices" "a sequence of upward-slices" }
65 { $description "Returns an array of monotonically increasing slices of type " { $link downward-slice } ". Slices of one element are discarded." } ;
70 { "slices" "a sequence of downward, stable, and upward slices" }
72 { $description "Returns a sorted sequence of downward, stable, or upward slices. The endpoints of some slices may overlap with each other." }
75 "USING: splitting.monotonic math prettyprint ;"
76 "{ 1 2 3 3 2 1 } trends ."
81 { seq { 1 2 3 3 2 1 } }
86 { seq { 1 2 3 3 2 1 } }
91 { seq { 1 2 3 3 2 1 } }
97 ARTICLE: "splitting.monotonic" "Splitting trending sequences"
98 "The " { $vocab-link "splitting.monotonic" } " vocabulary splits sequences that are trending downwards, upwards, or stably." $nl
99 "Splitting into sequences:"
100 { $subsection monotonic-split }
101 "Splitting into slices:"
102 { $subsection monotonic-slice }
104 { $subsection downward-slices }
105 { $subsection stable-slices }
106 { $subsection upward-slices }
107 { $subsection trends } ;
109 ABOUT: "splitting.monotonic"