| 
									
										
										
										
											2009-01-08 18:01:27 -05:00
										 |  |  | ! Copyright (C) 2009 Doug Coleman. | 
					
						
							|  |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2009-09-20 23:42:40 -04:00
										 |  |  | USING: help.markup help.syntax kernel quotations classes sequences ;
 | 
					
						
							| 
									
										
										
										
											2009-01-08 18:01:27 -05:00
										 |  |  | IN: splitting.monotonic | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-17 13:26:29 -04:00
										 |  |  | HELP: monotonic-split-slice | 
					
						
							| 
									
										
										
										
											2009-01-08 18:01:27 -05:00
										 |  |  | { $values | 
					
						
							| 
									
										
										
										
											2015-07-17 13:26:29 -04:00
										 |  |  |      { "seq" sequence } { "quot" { $quotation ( obj1 obj2 -- ? ) } } | 
					
						
							|  |  |  |      { "pieces" "a sequence of slices" } | 
					
						
							| 
									
										
										
										
											2009-01-08 18:01:27 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-07-17 13:26:29 -04:00
										 |  |  | { $description "Monotonically splits a sequence into slices." } | 
					
						
							| 
									
										
										
										
											2009-01-08 18:01:27 -05:00
										 |  |  | { $examples | 
					
						
							|  |  |  |     { $example | 
					
						
							|  |  |  |         "USING: splitting.monotonic math prettyprint ;" | 
					
						
							| 
									
										
										
										
											2015-07-17 13:26:29 -04:00
										 |  |  |         "{ 1 2 3 2 3 4 } [ < ] monotonic-split-slice ." | 
					
						
							| 
									
										
										
										
											2015-07-26 01:59:56 -04:00
										 |  |  |         "{ | 
					
						
							| 
									
										
										
										
											2015-07-17 13:26:29 -04:00
										 |  |  |     T{ slice { to 3 } { seq { 1 2 3 2 3 4 } } } | 
					
						
							|  |  |  |     T{ slice { from 3 } { to 6 } { seq { 1 2 3 2 3 4 } } } | 
					
						
							| 
									
										
										
										
											2015-07-26 01:59:56 -04:00
										 |  |  | }" | 
					
						
							| 
									
										
										
										
											2009-01-08 18:01:27 -05:00
										 |  |  |     } | 
					
						
							|  |  |  | } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: monotonic-split | 
					
						
							|  |  |  | { $values | 
					
						
							|  |  |  |      { "seq" sequence } { "quot" quotation } | 
					
						
							| 
									
										
										
										
											2015-07-17 13:26:29 -04:00
										 |  |  |      { "pieces" "a sequence of sequences" } | 
					
						
							| 
									
										
										
										
											2009-01-08 18:01:27 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-18 05:51:16 -05:00
										 |  |  | { $description "Splits a sequence into subsequences, in which for all consecutive pairs of elements the quotation returns true." } | 
					
						
							| 
									
										
										
										
											2009-01-08 18:01:27 -05:00
										 |  |  | { $examples | 
					
						
							|  |  |  |     { $example | 
					
						
							|  |  |  |         "USING: splitting.monotonic math prettyprint ;" | 
					
						
							|  |  |  |         "{ 1 2 3 2 3 4 } [ < ] monotonic-split ." | 
					
						
							| 
									
										
										
										
											2015-07-17 13:26:29 -04:00
										 |  |  |         "{ { 1 2 3 } { 2 3 4 } }" | 
					
						
							| 
									
										
										
										
											2009-01-08 18:01:27 -05:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-01-18 05:51:16 -05:00
										 |  |  |     { $example | 
					
						
							|  |  |  |         "USING: splitting.monotonic math prettyprint ;" | 
					
						
							|  |  |  |         "{ 1 2 3 2 1 0 } [ < ] monotonic-split ." | 
					
						
							|  |  |  |         "{ { 1 2 3 } { 2 } { 1 } { 0 } }" | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-01-08 18:01:27 -05:00
										 |  |  | } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-18 05:51:16 -05:00
										 |  |  | { monotonic-split monotonic-split-slice } related-words | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-08 18:01:27 -05:00
										 |  |  | HELP: downward-slices | 
					
						
							|  |  |  | { $values | 
					
						
							|  |  |  |      { "seq" sequence } | 
					
						
							|  |  |  |      { "slices" "a sequence of downward-slices" } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | { $description "Returns an array of monotonically decreasing slices of type " { $link downward-slice } ". Slices of one element are discarded." } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: stable-slices | 
					
						
							|  |  |  | { $values | 
					
						
							|  |  |  |     { "seq" sequence } | 
					
						
							|  |  |  |     { "slices" "a sequence of stable-slices" } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | { $description "Returns an array of monotonically decreasing slices of type " { $link downward-slice } ". Slices of one element are discarded." } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: upward-slices | 
					
						
							|  |  |  | { $values | 
					
						
							|  |  |  |     { "seq" sequence } | 
					
						
							|  |  |  |     { "slices" "a sequence of upward-slices" } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | { $description "Returns an array of monotonically increasing slices of type " { $link downward-slice } ". Slices of one element are discarded." } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: trends | 
					
						
							|  |  |  | { $values | 
					
						
							|  |  |  |     { "seq" sequence } | 
					
						
							|  |  |  |     { "slices" "a sequence of downward, stable, and upward slices" } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | { $description "Returns a sorted sequence of downward, stable, or upward slices. The endpoints of some slices may overlap with each other." } | 
					
						
							|  |  |  | { $examples | 
					
						
							|  |  |  |     { $example | 
					
						
							|  |  |  |         "USING: splitting.monotonic math prettyprint ;" | 
					
						
							|  |  |  |         "{ 1 2 3 3 2 1 } trends ." | 
					
						
							| 
									
										
										
										
											2015-07-26 01:59:56 -04:00
										 |  |  |         "{ | 
					
						
							| 
									
										
										
										
											2015-07-16 20:20:41 -04:00
										 |  |  |     T{ upward-slice { to 3 } { seq { 1 2 3 3 2 1 } } } | 
					
						
							| 
									
										
										
										
											2009-01-08 18:01:27 -05:00
										 |  |  |     T{ stable-slice | 
					
						
							|  |  |  |         { from 2 } | 
					
						
							|  |  |  |         { to 4 } | 
					
						
							|  |  |  |         { seq { 1 2 3 3 2 1 } } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     T{ downward-slice | 
					
						
							|  |  |  |         { from 3 } | 
					
						
							|  |  |  |         { to 6 } | 
					
						
							|  |  |  |         { seq { 1 2 3 3 2 1 } } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-07-26 01:59:56 -04:00
										 |  |  | }" | 
					
						
							| 
									
										
										
										
											2009-01-08 18:01:27 -05:00
										 |  |  |     } | 
					
						
							|  |  |  | } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ARTICLE: "splitting.monotonic" "Splitting trending sequences" | 
					
						
							|  |  |  | "The " { $vocab-link "splitting.monotonic" } " vocabulary splits sequences that are trending downwards, upwards, or stably." $nl | 
					
						
							|  |  |  | "Splitting into sequences:" | 
					
						
							| 
									
										
										
										
											2009-10-01 15:56:36 -04:00
										 |  |  | { $subsections monotonic-split } | 
					
						
							| 
									
										
										
										
											2009-01-08 18:01:27 -05:00
										 |  |  | "Splitting into slices:" | 
					
						
							| 
									
										
										
										
											2015-07-17 13:26:29 -04:00
										 |  |  | { $subsections monotonic-split-slice } | 
					
						
							| 
									
										
										
										
											2009-01-08 18:01:27 -05:00
										 |  |  | "Trending:" | 
					
						
							| 
									
										
										
										
											2009-10-01 15:56:36 -04:00
										 |  |  | { $subsections | 
					
						
							|  |  |  |     downward-slices | 
					
						
							|  |  |  |     stable-slices | 
					
						
							|  |  |  |     upward-slices | 
					
						
							|  |  |  |     trends | 
					
						
							|  |  |  | } ;
 | 
					
						
							| 
									
										
										
										
											2009-01-08 18:01:27 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ABOUT: "splitting.monotonic" |