From 2bc238a0263ab72d1d1f0869de54f79ac041a224 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 25 Jul 2022 21:27:47 -0500 Subject: [PATCH] sequences: fix e/i and i/e and remove maybe-nth with suggestion from @mrjbq7 --- core/sequences/sequences.factor | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 87aa6f6465..cf4514ff90 100644 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -182,9 +182,6 @@ PRIVATE> : ?set-nth ( elt n seq -- ) 2dup bounds-check? [ set-nth-unsafe ] [ 3drop ] if ; inline -: maybe-nth ( i/f seq -- elt/f ) - over [ nth ] [ 2drop f ] if ; inline - : ?first ( seq -- elt/f ) 0 swap ?nth ; inline : ?second ( seq -- elt/f ) 1 swap ?nth ; inline : ?last ( seq -- elt/f ) @@ -459,10 +456,10 @@ PRIVATE> [ setup-3each ] dip compose ; inline : element/index ( i/f seq -- elt/f i/f ) - [ maybe-nth ] [ drop ] 2bi ; inline + '[ [ _ nth ] [ f ] if* ] keep ; -: index/element ( i/f seq -- elt/f i/f ) - [ drop ] [ maybe-nth ] 2bi ; inline +: index/element ( i/f seq -- i/f elt/f ) + dupd '[ _ nth ] [ f ] if* ; : (accumulate) ( seq identity quot -- identity seq quot' ) swapd [ keepd ] curry ; inline -- 2.34.1