{ $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 } }
: 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