> Niklas Hambüchen <mail <at> nh2.me> writes:
> 
> > On 14/10/13 03:20, AntC wrote:
> > ... 
> > Then here's a further possible optimisation, instead of making 
> > separate calls to `member` and `insert`:
> 
> This I understand again. Where do you get insert' from? containers
> doesn't seem to have it. Do you suggest adding it?
> 

err, well I didn't have any specific library in mind.

More there's a kind of 'folk idiom' for managing data structures,
(this applies more for imperative code/update-in-situ than functional)
that if you know the next thing you're going to do after failing to find 
an element is insert it, you might as well get on with the insert there 
and then.

(It's a higher-level analogue of a machine instruction decrement-and-
branch-if-zero.)

I'm looking at all the remarks about managing libraries and dependencies.
Would it make sense to build a stand-alone version of Set purely to 
support ordNub? Then it needs only methods `empty` and `insertIfAbsent`.



_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to