[plt-scheme] Immutable mappings on symbols

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Fri Jan 21 18:16:11 EST 2005

Carl Eastlund wrote:

> I would like to see predicates like set?, map?, and (map-of thing?)
> exported from the galore units.  It would be nice to be able to check
> that, or to put contracts on modules which use these datatypes.  If
> these exist, I don't see them in the documentation.

I know from a reliable source that the documentation is up-to-date. [*]

If you look at the source of the various implementations of sets,
you won't see set? anywhere. Pushed harded I'll admit that it is a bit
odd. That's what happen, when you main source of inspiration uses SML.

Adding set? isn't difficult. I'll put it in the next version. Thanks
for bringing this to my attention.

Note however, that not all set implementations use datatypes separate
from the r5rs-ones. Concretely the sets-as-sorted-lists implementation
on purpose use normal lists to implement sets. Thus set? is not always
O(1) as one might expect.

If you are in immediate need for set? an easy solution is to make
your own set module that wraps a Galore set in a new struct.


About map: Maps aren't in the current Galore, but they will
hopefully appear at some point. In the mean there is no problem using
the various search trees for sets to implement your own maps.


[*] Ambiguity intended.

-- 
Jens Axel Søgaard




Posted on the users mailing list.