math-binpack: Fix incorrect array size, and update tests.

db4
John Benediktsson 2008-10-01 20:05:08 -07:00
parent b0ad7dfebc
commit bce227c8f3
2 changed files with 7 additions and 5 deletions

View File

@ -1,11 +1,13 @@
! Copyright (C) 2008 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: kernel tools.test ;
USING: kernel tools.test math.binpack ;
[ t ] [ { { 3 } { 2 1 } } { 1 2 3 } 2 binpack-numbers = ] unit-test
[ t ] [ { V{ } } { } 1 binpack = ] unit-test
[ t ] [ { { 1000 } { 100 30 } { 70 40 23 } { 60 60 7 3 } }
{ 100 23 40 60 1000 30 60 07 70 03 } 3 binpack-numbers = ] unit-test
[ t ] [ { { 3 } { 2 1 } } { 1 2 3 } 2 binpack* = ] unit-test
[ t ] [ { { 1000 } { 100 60 30 7 } { 70 60 40 23 3 } }
{ 100 23 40 60 1000 30 60 07 70 03 } 3 binpack* = ] unit-test

View File

@ -10,7 +10,7 @@ IN: math.binpack
: binpack ( assoc n -- bins )
[ sort-values reverse [ length ] keep swap ] dip
[ / ceiling ] keep <array> [ <vector> ] map
[ / ceiling ] keep swap <array> [ <vector> ] map
swap [ dupd (binpack) ] each ;
: binpack* ( items n -- bins )