On Fri, May 27, 2011 at 2:27 AM, Sunil S Nandihalli
wrote:
> I don't think yours is going to be anymore efficient than the one I had
> initially posted .. In fact it might be slower in majority of the cases..
Yes; yours will terminate as soon as it finds a "hole" in the
numbering, whereas Walter'
I don't think yours is going to be anymore efficient than the one I had
initially posted .. In fact it might be slower in majority of the cases..
Thanks,
Sunil.
On Fri, May 27, 2011 at 12:57 AM, Walter van der Laan <
waltervanderl...@gmail.com> wrote:
> You could use this:
> (defn non-existing-ke
You could use this:
(defn non-existing-key [mp] (inc (reduce max (keys mp
For example:
(non-existing-key {1 "a" 2 "b"}) => 3
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that p
If you have control over the creation of the map, you could use something like
a global counter to provide the next valid key.
You could also use a sorted map and just increment to last (biggest) key in the
map.
Or you could use a random number. If the range is big enough, the probability
of col
Hello everybody,
I was wondering if there is a way to find a key which does not exist in a
map in an efficient way. you can assume that all the keys are integers.
I currently do something like
(defn non-existent-key [mp]
(first (filter (comp not mp) (range
Is there a possibly m