sequences: slightly faster ?last.

db4
John Benediktsson 2012-07-27 09:12:29 -07:00
parent 2f93d9dedd
commit a7fff4f192
1 changed files with 3 additions and 1 deletions

View File

@ -177,7 +177,9 @@ PRIVATE>
: ?first ( seq -- elt/f ) 0 swap ?nth ; inline
: ?second ( seq -- elt/f ) 1 swap ?nth ; inline
: ?last ( seq -- elt/f ) [ length 1 - ] [ ?nth ] bi ; inline
: ?last ( seq -- elt/f )
[ length 1 - ] keep over 0 <
[ 2drop f ] [ nth-unsafe ] if ; inline
MIXIN: virtual-sequence
GENERIC: virtual-exemplar ( seq -- seq' )