sequences.extras: adding nth* which is nth from the end.
parent
0fcb485d80
commit
454bffc14e
|
@ -169,3 +169,5 @@ IN: sequences.extras.tests
|
|||
{ "foo" " " } [ "foo " [ blank? ] cut-when ] unit-test
|
||||
{ "" " foo" } [ " foo" [ blank? ] cut-when ] unit-test
|
||||
{ "foo" " bar" } [ "foo bar" [ blank? ] cut-when ] unit-test
|
||||
|
||||
{ { 4 0 3 1 2 } } [ { 0 4 1 3 2 } 5 iota [ nth* ] curry map ] unit-test
|
||||
|
|
|
@ -486,3 +486,6 @@ PRIVATE>
|
|||
: cut-when ( ... seq quot: ( ... elt -- ... ? ) -- ... before after )
|
||||
[ find drop ] 2keep drop swap
|
||||
[ cut ] [ f over like ] if* ; inline
|
||||
|
||||
: nth* ( n seq -- elt )
|
||||
[ length 1 - swap - ] [ nth ] bi ; inline
|
||||
|
|
Loading…
Reference in New Issue