core: Use integer>fixnum instead of >fixnum for ``nth`` and other sequence operations. Fixes #581.
parent
106ecdb6dd
commit
4a14bd407d
|
@ -5,8 +5,8 @@ IN: arrays
|
||||||
|
|
||||||
M: array clone (clone) ; inline
|
M: array clone (clone) ; inline
|
||||||
M: array length length>> ; inline
|
M: array length length>> ; inline
|
||||||
M: array nth-unsafe [ >fixnum ] dip array-nth ; inline
|
M: array nth-unsafe [ integer>fixnum ] dip array-nth ; inline
|
||||||
M: array set-nth-unsafe [ >fixnum ] dip set-array-nth ; inline
|
M: array set-nth-unsafe [ integer>fixnum ] dip set-array-nth ; inline
|
||||||
M: array resize resize-array ; inline
|
M: array resize resize-array ; inline
|
||||||
M: array equal? over array? [ sequence= ] [ 2drop f ] if ;
|
M: array equal? over array? [ sequence= ] [ 2drop f ] if ;
|
||||||
M: object new-sequence drop 0 <array> ; inline
|
M: object new-sequence drop 0 <array> ; inline
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
USING: arrays byte-arrays kernel math math.order math.parser
|
USING: arrays byte-arrays kernel math math.order math.parser
|
||||||
namespaces sequences kernel.private sequences.private strings
|
namespaces sequences kernel.private sequences.private strings
|
||||||
sbufs tools.test vectors assocs generic vocabs.loader ;
|
sbufs tools.test vectors assocs generic vocabs.loader
|
||||||
|
generic.single ;
|
||||||
IN: sequences.tests
|
IN: sequences.tests
|
||||||
|
|
||||||
[ "empty" ] [ { } [ "empty" ] [ "not empty" ] if-empty ] unit-test
|
[ "empty" ] [ { } [ "empty" ] [ "not empty" ] if-empty ] unit-test
|
||||||
|
@ -213,7 +214,9 @@ unit-test
|
||||||
|
|
||||||
[ V{ "a" "b" } V{ } ] [ { "X" "a" "b" } { "X" } drop-prefix [ >vector ] bi@ ] unit-test
|
[ V{ "a" "b" } V{ } ] [ { "X" "a" "b" } { "X" } drop-prefix [ >vector ] bi@ ] unit-test
|
||||||
|
|
||||||
[ 1 ] [ 0.5 { 1 2 3 } nth ] unit-test
|
[ 0.5 10 iota nth ] [ no-method? ] must-fail-with
|
||||||
|
[ 0.5 { 1 2 3 } nth ] [ no-method? ] must-fail-with
|
||||||
|
[ 0.5 "asdfasdf" nth ] [ no-method? ] must-fail-with
|
||||||
|
|
||||||
! Pathological case
|
! Pathological case
|
||||||
[ "ihbye" ] [ "hi" <reversed> "bye" append ] unit-test
|
[ "ihbye" ] [ "hi" <reversed> "bye" append ] unit-test
|
||||||
|
|
|
@ -106,7 +106,7 @@ TUPLE: iota { n integer read-only } ;
|
||||||
: iota ( n -- iota ) \ iota boa ; inline
|
: iota ( n -- iota ) \ iota boa ; inline
|
||||||
|
|
||||||
M: iota length n>> ; inline
|
M: iota length n>> ; inline
|
||||||
M: iota nth-unsafe drop ; inline
|
M: iota nth-unsafe drop integer>fixnum ; inline
|
||||||
|
|
||||||
INSTANCE: iota immutable-sequence
|
INSTANCE: iota immutable-sequence
|
||||||
|
|
||||||
|
@ -634,7 +634,7 @@ ERROR: assert-sequence got expected ;
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
: sequence-hashcode-step ( oldhash newpart -- newhash )
|
: sequence-hashcode-step ( oldhash newpart -- newhash )
|
||||||
>fixnum swap [
|
integer>fixnum swap [
|
||||||
[ -2 fixnum-shift-fast ] [ 5 fixnum-shift-fast ] bi
|
[ -2 fixnum-shift-fast ] [ 5 fixnum-shift-fast ] bi
|
||||||
fixnum+fast fixnum+fast
|
fixnum+fast fixnum+fast
|
||||||
] keep fixnum-bitxor ; inline
|
] keep fixnum-bitxor ; inline
|
||||||
|
@ -845,7 +845,7 @@ PRIVATE>
|
||||||
#! We can't use case here since combinators depends on
|
#! We can't use case here since combinators depends on
|
||||||
#! sequences
|
#! sequences
|
||||||
pick length dup 0 3 between? [
|
pick length dup 0 3 between? [
|
||||||
>fixnum {
|
integer>fixnum {
|
||||||
[ drop nip ]
|
[ drop nip ]
|
||||||
[ 2drop first ]
|
[ 2drop first ]
|
||||||
[ [ drop first2 ] dip call ]
|
[ [ drop first2 ] dip call ]
|
||||||
|
|
|
@ -63,11 +63,11 @@ M: string length
|
||||||
length>> ; inline
|
length>> ; inline
|
||||||
|
|
||||||
M: string nth-unsafe
|
M: string nth-unsafe
|
||||||
[ >fixnum ] dip string-nth ; inline
|
[ integer>fixnum ] dip string-nth ; inline
|
||||||
|
|
||||||
M: string set-nth-unsafe
|
M: string set-nth-unsafe
|
||||||
dup reset-string-hashcode
|
dup reset-string-hashcode
|
||||||
[ >fixnum ] [ >fixnum ] [ ] tri* set-string-nth ; inline
|
[ integer>fixnum ] [ integer>fixnum ] [ ] tri* set-string-nth ; inline
|
||||||
|
|
||||||
M: string clone
|
M: string clone
|
||||||
(clone) [ clone ] change-aux ; inline
|
(clone) [ clone ] change-aux ; inline
|
||||||
|
|
|
@ -18,7 +18,7 @@ M: vector like
|
||||||
] unless ; inline
|
] unless ; inline
|
||||||
|
|
||||||
M: vector new-sequence
|
M: vector new-sequence
|
||||||
drop [ f <array> ] [ >fixnum ] bi vector boa ; inline
|
drop [ f <array> ] [ integer>fixnum ] bi vector boa ; inline
|
||||||
|
|
||||||
M: vector equal?
|
M: vector equal?
|
||||||
over vector? [ sequence= ] [ 2drop f ] if ;
|
over vector? [ sequence= ] [ 2drop f ] if ;
|
||||||
|
|
Loading…
Reference in New Issue