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 ;
4 IN: splitting.monotonic
8 { "seq" sequence } { "quot" quotation } { "class" class }
9 { "slices" "a sequence of slices" }
11 { $description "Monotonically splits a sequence into slices of the type " { $snippet "class" } "." }
14 "USING: splitting.monotonic math prettyprint ;"
15 "{ 1 2 3 2 3 4 } [ < ] upward-slice monotonic-slice ."
20 { seq { 1 2 3 2 3 4 } }
25 { seq { 1 2 3 2 3 4 } }
33 { "seq" sequence } { "quot" quotation }
34 { "newseq" "a sequence of sequences" }
36 { $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." }
39 "USING: splitting.monotonic math prettyprint ;"
40 "{ 1 2 3 2 3 4 } [ < ] monotonic-split ."
41 "{ V{ 1 2 3 } V{ 2 3 4 } }"
48 { "slices" "a sequence of downward-slices" }
50 { $description "Returns an array of monotonically decreasing slices of type " { $link downward-slice } ". Slices of one element are discarded." } ;
55 { "slices" "a sequence of stable-slices" }
57 { $description "Returns an array of monotonically decreasing slices of type " { $link downward-slice } ". Slices of one element are discarded." } ;
62 { "slices" "a sequence of upward-slices" }
64 { $description "Returns an array of monotonically increasing slices of type " { $link downward-slice } ". Slices of one element are discarded." } ;
69 { "slices" "a sequence of downward, stable, and upward slices" }
71 { $description "Returns a sorted sequence of downward, stable, or upward slices. The endpoints of some slices may overlap with each other." }
74 "USING: splitting.monotonic math prettyprint ;"
75 "{ 1 2 3 3 2 1 } trends ."
80 { seq { 1 2 3 3 2 1 } }
85 { seq { 1 2 3 3 2 1 } }
90 { seq { 1 2 3 3 2 1 } }
96 ARTICLE: "splitting.monotonic" "Splitting trending sequences"
97 "The " { $vocab-link "splitting.monotonic" } " vocabulary splits sequences that are trending downwards, upwards, or stably." $nl
98 "Splitting into sequences:"
99 { $subsections monotonic-split }
100 "Splitting into slices:"
101 { $subsections monotonic-slice }
110 ABOUT: "splitting.monotonic"