]> gitweb.factorcode.org Git - factor.git/commitdiff
sequences.extras: adding map-index!.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 9 Aug 2012 03:07:38 +0000 (20:07 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 9 Aug 2012 03:07:38 +0000 (20:07 -0700)
extra/sequences/extras/extras.factor

index 6833ceed387c833623b09e5a520edca059232c0c..e353064aef07255a7f1904b817a22aa6559495e6 100644 (file)
@@ -224,3 +224,6 @@ PRIVATE>
     [ find ] 2keep rot [
         [ 1 + ] 2dip find-from drop not
     ] [ 3drop f ] if ; inline
+
+: map-index! ( ... seq quot: ( ... elt index -- ... newelt ) -- ... seq )
+    over [ [ (each-index) ] dip collect ] keep ; inline