Handbook
Glossary
binpack-clusters ( sizes -- bins blobs )
Vocabulary
zim
.
builder
Inputs
sizes
an
object
Outputs
bins
an
object
blobs
an
object
Definition
USING:
arrays
kernel
math
math.binpack
sequences
;
IN:
zim.builder
::
binpack-clusters
( sizes -- bins blobs )
sizes
[
CLUSTER-SIZE
>
]
partition
[
length
]
[
sum
CLUSTER-SIZE
/mod
zero?
[
1
+
]
unless
+
]
bi*
:>
#clusters #clusters sizes
length
<=
t
assert=
sizes
length
<iota>
[
sizes
nth
]
#clusters
map-binpack
:>
bins sizes
length
<iota>
[|
i | i bins
[
index
]
with
find
i
swap
index
2array
]
map
:>
blobs bins blobs
;