splitting.monotonic: Don't throw away the last result. Fixes #462.
parent
b094d4d0ec
commit
6fdf24d5b4
|
@ -53,3 +53,19 @@ USING: tools.test math arrays kernel sequences ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
] [ { 1 2 3 3 2 1 } trends ] unit-test
|
] [ { 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
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
! Copyright (C) 2008, 2009 Doug Coleman.
|
! Copyright (C) 2008, 2009 Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: make namespaces sequences kernel fry arrays compiler.utilities
|
USING: accessors arrays circular combinators
|
||||||
math accessors circular grouping combinators sorting math.order ;
|
combinators.short-circuit compiler.utilities fry grouping
|
||||||
|
kernel make math math.order namespaces sequences sorting ;
|
||||||
IN: splitting.monotonic
|
IN: splitting.monotonic
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
@ -27,12 +28,16 @@ PRIVATE>
|
||||||
[
|
[
|
||||||
dupd '[
|
dupd '[
|
||||||
[ length iota ] [ ] [ <circular> 1 over change-circular-start ] tri
|
[ length iota ] [ ] [ <circular> 1 over change-circular-start ] tri
|
||||||
[ @ not [ , ] [ drop ] if ] 3each
|
[ @ not [ 1 + , ] [ drop ] if ] 3each
|
||||||
] { } make
|
] { } 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
|
swap
|
||||||
] dip
|
] dip
|
||||||
'[ first2 [ 1 + ] bi@ _ _ boa ] map ; inline
|
'[ first2 _ _ boa ] map ; inline
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue