sequences.extras: additional tests for take-while and drop-while.
parent
e462f85c66
commit
369f5b6d13
|
@ -247,6 +247,8 @@ IN: sequences.extras.tests
|
|||
|
||||
{ { 0 1 2 3 } } [ 8 iota [ 4 < ] take-while >array ] unit-test
|
||||
{ { } } [ { 15 16 } [ 4 < ] take-while >array ] unit-test
|
||||
{ { 0 1 2 } } [ 3 iota [ 4 < ] take-while >array ] unit-test
|
||||
|
||||
{ { 4 5 6 7 } } [ 8 iota [ 4 < ] drop-while >array ] unit-test
|
||||
{ { 15 16 } } [ { 15 16 } [ 4 < ] drop-while >array ] unit-test
|
||||
{ { } } [ 3 iota [ 4 < ] drop-while >array ] unit-test
|
||||
|
|
|
@ -604,7 +604,9 @@ PRIVATE>
|
|||
'[ swap _ dip swap ] assoc-map ; inline
|
||||
|
||||
: take-while ( ... seq quot: ( ... elt -- ... ? ) -- head-slice )
|
||||
[ '[ @ not ] find drop ] 2keep drop swap 0 or head-slice ; inline
|
||||
[ '[ @ not ] find drop ] 2keep drop swap
|
||||
[ dup length ] unless* head-slice ; inline
|
||||
|
||||
: drop-while ( ... seq quot: ( ... elt -- ... ? ) -- tail-slice )
|
||||
[ '[ @ not ] find drop ] 2keep drop swap 0 or tail-slice ; inline
|
||||
[ '[ @ not ] find drop ] 2keep drop swap
|
||||
[ dup length ] unless* tail-slice ; inline
|
||||
|
|
Loading…
Reference in New Issue