----- Original Message -----
From: Phil Hagelberg <p...@hagelb.org>
Sent: Wednesday 11 February 2009 13:16

> 
> Jason Wolfe <jawo...@berkeley.edu> writes:
> 
> >> Would you consider changing the names of these 2 functions ?
> >>
> >> random-permutation -> shuffle
> >> random-element -> one-of
> >>
> >> Shorter names are a trademark of clojure.
> >> "one-of" was taken straight from paip =)
> >
> > I'd be OK with shuffle, I guess, but I don't know if one-of is  
> > descriptive enough for my taste.  I feel like neither are used so  
> > often that a slightly longer and descriptive name isn't merited.
> 
> I'm not a fan of "one-of". If it has to be shorter, perhaps "pick-rand"?
> 
> -Phil

I wrote essentially the same function as "random-element", but let it take a 
collection. It looked like "nth" without the index arg, so I called it 
"rand-nth".

(defn rand-nth 
  [coll]
  (nth (seq coll) (rand-int (count coll))))

One more naming option anyway.

- Jeff

--~--~---------~--~----~------------~-------~--~----~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to