sequences: nths should return a sequence of the same type as the original (reported by Jon Harper)
parent
09848ab420
commit
c2aca44b4a
|
@ -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 ;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue