From d4b01a84de6cc5a6e07e038f6d4fec1d0917dd40 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 24 Feb 2023 23:20:14 -0600 Subject: [PATCH] sequences: move ??nth --- core/sequences/sequences-docs.factor | 6 +----- core/sequences/sequences.factor | 6 ++---- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index 1ae56566fd..f75224c53f 100644 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -180,11 +180,7 @@ HELP: ?nth { $values { "n" integer } { "seq" sequence } { "elt/f" { $maybe object } } } { $description "A forgiving version of " { $link nth } ". If the index is out of bounds, or if the sequence is " { $link f } ", simply outputs " { $link f } "." } ; -HELP: ??nth -{ $values { "n" integer } { "seq" sequence } { "elt/f" { $maybe object } } { "?" boolean } } -{ $description "A forgiving version of " { $link nth } ". If the index is out of bounds, or if the sequence is " { $link f } ", simply outputs " { $link f } ". Also outputs a boolean to distinguish between the sequence containing an " { $link f } " or an out of bounds index." } ; - -{ nth ?nth ??nth } related-words +{ nth ?nth } related-words HELP: ?set-nth { $values { "elt" object } { "n" integer } { "seq" sequence } } diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 1716e5ce97..7759cf3bac 100644 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -180,10 +180,8 @@ PRIVATE> : first4 ( seq -- first second third fourth ) 3 swap bounds-check nip first4-unsafe ; inline -: ??nth ( n seq -- elt/f ? ) - 2dup bounds-check? [ nth-unsafe t ] [ 2drop f f ] if ; inline - -: ?nth ( n seq -- elt/f ) ??nth drop ; inline + : ?nth ( n seq -- elt/f ) + 2dup bounds-check? [ nth-unsafe ] [ 2drop f ] if ; inline : ?set-nth ( elt n seq -- ) 2dup bounds-check? [ set-nth-unsafe ] [ 3drop ] if ; inline -- 2.34.1