collections: add cut word
parent
19510ea5a7
commit
0e6fd48c11
|
@ -256,4 +256,7 @@ IN: sequences.extras.tests
|
|||
[ undefined-find-nth? ] must-fail-with
|
||||
|
||||
{ { 1 1 2 1 } }
|
||||
[ 3 { 1 1 2 1 } [ 2 = not ] head-nth ] unit-test
|
||||
[ 3 { 1 1 2 1 1 1 } [ 2 = not ] head-nth-match ] unit-test
|
||||
|
||||
{ { 1 1 2 1 } { 1 1 } }
|
||||
[ 3 { 1 1 2 1 1 1 } [ 2 = not ] cut-nth-match ] unit-test
|
|
@ -627,12 +627,20 @@ ERROR: undefined-find-nth m n seq quot ;
|
|||
: find-last-nth ( n seq quot -- i/f elt/f )
|
||||
[ [ nip length 1 - ] [ ] 2bi ] dip find-last-nth-from ; inline
|
||||
|
||||
ERROR: head-nth-reached-end n seq quot ;
|
||||
:: head-nth ( n seq quot -- seq' )
|
||||
ERROR: combinator-nth-reached-end n seq quot ;
|
||||
|
||||
:: head-nth-match ( n seq quot -- seq' )
|
||||
n seq quot find-nth drop [
|
||||
[ seq ] dip 1 + head
|
||||
] [
|
||||
n seq quot head-nth-reached-end
|
||||
n seq quot combinator-nth-reached-end
|
||||
] if* ; inline
|
||||
|
||||
:: cut-nth-match ( n seq quot -- seq' )
|
||||
n seq quot find-nth drop [
|
||||
[ seq ] dip 1 + head
|
||||
] [
|
||||
n seq quot combinator-nth-reached-end
|
||||
] if* ; inline
|
||||
|
||||
:: (start-all) ( subseq seq increment -- indices )
|
||||
|
|
Loading…
Reference in New Issue