}
}
] [ { 1 2 3 3 2 1 } trends ] unit-test
+
+
+[ { { 2 2 } { 3 3 3 3 } { 4 } { 5 } } ]
+[
+ { 2 2 3 3 3 3 4 5 }
+ [ [ odd? ] bi@ = ] slice monotonic-slice
+ [ >array ] map
+] unit-test
+
+[
+ { { 1 1 1 } { 2 2 2 2 } { 3 3 } }
+] [
+ { 1 1 1 2 2 2 2 3 3 }
+ [ [ odd? ] bi@ = ] slice monotonic-slice
+ [ >array ] map
+] unit-test
! Copyright (C) 2008, 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: make namespaces sequences kernel fry arrays compiler.utilities
-math accessors circular grouping combinators sorting math.order ;
+USING: accessors arrays circular combinators
+combinators.short-circuit compiler.utilities fry grouping
+kernel make math math.order namespaces sequences sorting ;
IN: splitting.monotonic
<PRIVATE
[
dupd '[
[ length iota ] [ ] [ <circular> 1 over change-circular-start ] tri
- [ @ not [ , ] [ drop ] if ] 3each
+ [ @ not [ 1 + , ] [ drop ] if ] 3each
] { } make
- dup empty? [ over length 1 - prefix ] when -1 prefix 2 clump
+ 2dup {
+ [ nip empty? ]
+ [ [ length ] [ last ] bi* = not ]
+ } 2|| [ over length suffix ] when
+ 0 prefix 2 clump
swap
] dip
- '[ first2 [ 1 + ] bi@ _ _ boa ] map ; inline
+ '[ first2 _ _ boa ] map ; inline
PRIVATE>