[Prev][Next][Index][Thread]

Initial filling of collections



Hi all,

we all use and love the fill: keyword when making collections as in

make(<vector>, size: 42, fill: #"foo");

If this keyword is not provided, the default is #f, which seems inappropriate for limited collections over a different element type than type-union(#f.singleton, XXX).

In this case you have to come up with an arbitrary init value, specify it in \make and than fill in computed values with map-into!.


I am wondering how this could be combined into a single pass and whether fill-function: can be provided that accepts a key and returns an initial value for make? (Of course this is for <sequence>s,
for <explicit-key-collection>s the signature would be "method() => (key, value)")

What I envision is something like this:

make(limited(<vector>, of: <integer>), size: 42, fill-function: identity);

this would be a performance-wise and logically better alternative to the compound

map-into!(identity, make(limited(<vector>, of: <integer>), size: 42, fill: 0));


Would such an extension make sense or even have a chance to make it into a future DRM?
Any thoughts?

Or am I missing something obvious?

Thanks,

	Gabor



Follow-Ups: