Moved monotonic-split to sequences.lib

release
Doug Coleman 2007-10-31 16:03:06 -05:00
parent 485d454f1d
commit a86a138b08
2 changed files with 1 additions and 15 deletions

View File

@ -1,9 +1,5 @@
USING: arrays kernel math roman roman.private sequences tools.test ;
[ { { 1 } { -1 5 } { 2 4 } } ]
[ { 1 -1 5 2 4 } [ < ] monotonic-split [ >array ] map ] unit-test
[ { { 1 1 1 1 } { 2 2 } { 3 } { 4 } { 5 } { 6 6 6 } } ]
[ { 1 1 1 1 2 2 3 4 5 6 6 6 } [ = ] monotonic-split [ >array ] map ] unit-test
[ "i" ] [ 1 >roman ] unit-test
[ "ii" ] [ 2 >roman ] unit-test
[ "iii" ] [ 3 >roman ] unit-test

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license.
USING: arrays assocs kernel math math.vectors namespaces
quotations sequences sequences.private strings ;
quotations sequences sequences.lib sequences.private strings ;
IN: roman
<PRIVATE
@ -22,16 +22,6 @@ TUPLE: roman-range-error n ;
roman-range-error construct-boa throw
] if ;
: ,, building get peek push ;
: v, V{ } clone , ;
: ,v building get dup peek empty? [ dup pop* ] when drop ;
: monotonic-split ( seq quot -- newseq )
[
>r dup unclip add r>
v, [ pick ,, call [ v, ] unless ] curry 2each ,v
] { } make ;
: roman<= ( ch1 ch2 -- ? )
[ 1string roman-digits index ] 2apply >= ;