sequences.extras: fix bug in count-head, add some tests.
parent
739742d0ae
commit
6e89e4ecab
|
@ -273,3 +273,11 @@ tools.test vectors vocabs ;
|
|||
{ "a_b" } [ "ab" CHAR: _ interleaved ] unit-test
|
||||
{ "a_b_c" } [ "abc" CHAR: _ interleaved ] unit-test
|
||||
{ "a_b_c_d" } [ "abcd" CHAR: _ interleaved ] unit-test
|
||||
|
||||
{ 0 } [ { 1 2 3 4 } [ 5 > ] count-head ] unit-test
|
||||
{ 2 } [ { 1 2 3 4 } [ 3 < ] count-head ] unit-test
|
||||
{ 4 } [ { 1 2 3 4 } [ 5 < ] count-head ] unit-test
|
||||
|
||||
{ 0 } [ { 1 2 3 4 } [ 5 > ] count-tail ] unit-test
|
||||
{ 2 } [ { 1 2 3 4 } [ 2 > ] count-tail ] unit-test
|
||||
{ 4 } [ { 1 2 3 4 } [ 5 < ] count-tail ] unit-test
|
||||
|
|
|
@ -629,7 +629,7 @@ PRIVATE>
|
|||
[ dup length ] unless* tail-slice ; inline
|
||||
|
||||
: count-head ( seq quot -- n )
|
||||
[ not ] compose find drop ; inline
|
||||
[ not ] compose [ find drop ] 2keep drop length or ; inline
|
||||
|
||||
: count-tail ( seq quot -- n )
|
||||
[ not ] compose [ find-last drop ] 2keep drop
|
||||
|
|
Loading…
Reference in New Issue