3 ms·
Functional programmers tend to avoid iterators since they aren't referentially transparent. Instead, operations on collections are expressed with higher-order
by rkts 19y ago
Functional programmers tend to avoid iterators since they aren't referentially transparent. Instead, operations on collections are expressed with higher-order functions that map or fold some function over each element. If you need a first-class "conventional interface" to sequential data, the preferred structure is the linked list.
Hash tables in functional-style languages often let you specify a hash function. That means the hash function is a property of the collection, rather than the objects in it. If you prefer a more "object-oriented" design, you can use an object system such as tinyclos to define a generic hash function. But Schemers usually like to avoid such complexity.
Looking at the PLT documentation, I see that its hash tables don't let you specify a hash function. That's definitely a shortcoming, though arguably not a serious one in practice. SRFI 69 gets this right.
- Tichy 19y agoThanks for the info! I definitely prefer the map or fold approach, however, the MzScheme has a (give-me-next-element n)-approach, which I didn't like at first sight. I will check out the references you gave (tinyclos etc).