]> gitweb.factorcode.org Git - factor.git/commitdiff
sequences: nths should return a sequence of the same type as the original (reported...
authorSlava Pestov <slava@factorcode.org>
Sat, 29 Jan 2011 05:18:36 +0000 (00:18 -0500)
committerSlava Pestov <slava@factorcode.org>
Sat, 29 Jan 2011 05:18:36 +0000 (00:18 -0500)
core/sequences/sequences-tests.factor
core/sequences/sequences.factor

index 175ab252e13af9c1d62658e1b304c0d200d3458b..586e312edbcf1cc8fc7db9e1c844bb16af73485c 100644 (file)
@@ -255,6 +255,8 @@ unit-test
 [ { "a" "b" "c" "d" } ] [ { 0 1 2 3 } { "a" "b" "c" "d" } nths ] unit-test
 [ { "d" "c" "b" "a" } ] [ { 3 2 1 0 } { "a" "b" "c" "d" } nths ] unit-test
 [ { "d" "a" "b" "c" } ] [ { 3 0 1 2 } { "a" "b" "c" "d" } nths ] unit-test
+
+[ "dac" ] [ { 3 0 2 } "abcd" nths ] unit-test
                           
 TUPLE: bogus-hashcode ;
 
index 55398ff02bedc45b6a02d5ab0b0d015295a8a954..493365db1afa444d133db7dab77c433938bbd756 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2005, 2010 Slava Pestov, Daniel Ehrenberg.
+! Copyright (C) 2005, 2011 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel kernel.private slots.private math
 math.private math.order ;
@@ -559,7 +559,7 @@ PRIVATE>
     [ [ (indices) ] 2curry each-index ] keep ;
 
 : nths ( indices seq -- seq' )
-    [ nth ] curry map ;
+    [ [ nth ] curry ] keep map-as ;
 
 : any? ( ... seq quot: ( ... elt -- ... ? ) -- ... ? )
     find drop >boolean ; inline