]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/sequences/extras/extras.factor
sequences: move words to extras
[factor.git] / extra / sequences / extras / extras.factor
index 350b41d5e725650aee0e2d0cad9647af4e328a4a..1d5dc80b97ed8aa862ba05f5c30aad1992729655 100644 (file)
@@ -323,6 +323,18 @@ PRIVATE>
 : 1reduce ( seq quot: ( prev elt -- next ) -- result )
     [ ?unclip ] dip reduce ; inline
 
+<PRIVATE
+
+: change-nth-of-unsafe ( seq i quot -- seq )
+    [ [ nth-of-unsafe ] dip call ] 2keepd rot set-nth-of-unsafe ; inline
+
+PRIVATE>
+
+: nth-of ( seq n -- elt ) swap nth ; inline
+: set-nth-of ( seq n elt -- seq ) spin [ set-nth ] keep ; inline
+: ?nth-of ( seq n -- elt/f ) swap ?nth ; inline
+: ??nth-of ( seq n -- elt/f ? ) swap ??nth ; inline
+
 : reduce-of ( seq quot: ( prev elt -- next ) identity -- result )
     swap reduce ; inline