3 ms·
Right, seq looks like a single way of accessing various collections when you need to access them in a specific manner. If I want to access the collection itera
by scotty79 5y ago
Right, seq looks like a single way of accessing various collections when you need to access them in a specific manner.
If I want to access the collection iterating through it in read-only manner I'd just use seq. But I'm not guaranteed that ISeq I got will be fast. It will be as fast as possible for my collection, but what I want is to create a sequence where ISeq is fast, and also for example which I can access and modify by index and also where I can add values in front fast, and also possibly some other requirements.
Basically what I want is the ability to specify which operations I need to be fast at creation time, and get appropriate collection for that. And syntax of those operations should not change if requirements change.
Simpler way might be defining which data structures I want my collections to use, and get fast operations enabled by those data structures through common syntax.
For example:
var mp = string[] is array, set, stack
mp[5] = 'hello'
mp.has('hello')
mp.pop()
are all fast.