fix each-bit for negative inputs

cvs
Slava Pestov 2006-01-02 21:35:37 +00:00
parent c52cffea19
commit 2883f8a5f5
4 changed files with 8 additions and 6 deletions

View File

@ -215,7 +215,7 @@ vectors words ;
"/library/collections/strings.facts"
"/library/collections/tree-each.facts"
"/library/collections/vectors.facts"
"/library/collections/virtual-sequence.facts"
"/library/collections/virtual-sequences.facts"
"/library/syntax/parse-syntax.factor"

View File

@ -95,9 +95,6 @@ M: simple-element print-element [ print-element ] each ;
: textual-list ( seq quot -- )
[ "," format* bl ] interleave ; inline
: $see-also ( content -- )
"See also" $subheading [ 1array $link ] textual-list ;
: $see ( content -- )
terpri*
code-style [ [ first see ] with-nesting* ] with-style
@ -142,6 +139,9 @@ DEFER: help
: $definition ( content -- )
"Definition" $subheading $see ;
: $see-also ( content -- )
"See also" $subheading [ 1array $link ] textual-list ;
: $predicate ( content -- )
{ { "object" "an object" } } $values
"Tests if the top of the stack is " $description

View File

@ -29,7 +29,7 @@ M: number ^ ( z w -- z^w )
: each-bit ( n quot -- | quot: 0/1 -- )
#! Apply the quotation to each bit of the number. The number
#! must be positive.
over 0 number= [
over 0 number= pick -1 number= or [
2drop
] [
2dup >r >r >r 1 bitand r> call r> -1 shift r> each-bit

View File

@ -1,5 +1,5 @@
IN: temporary
USING: kernel math prettyprint test ;
USING: kernel math namespaces prettyprint test ;
[ "-8" ] [ -8 unparse ] unit-test
@ -97,3 +97,5 @@ unit-test
[ 0 ] [ -1 -268435456 >fixnum /i ] unit-test
[ 0 -1 ] [ -1 -268435456 >fixnum /mod ] unit-test
[ 14355 ] [ 1591517158873146351817850880000000 32769 mod ] unit-test
[ { 0 1 1 0 } ] [ [ -10 [ , ] each-bit ] { } make ] unit-test