From TinyMUX
Revision as of 05:55, 17 January 2006 by Ian (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


FUNCTION: 20px-Function.png pickrand(word1 word2 <...wordN[,delimiter])

This function picks a random element from a list. It's faster than first(shuffle(foo)) or extract(foo,rand(words(foo)),1). delimiter is an optional one-character output delimiter.

Related Topics: die(), lrand(), rand(), shuffle(), first(), extract()


> say pickrand(foo bar baz)
You say "bar"
Pick a random DOING when you connect:
> &LIST.DOINGS me=Doing This|Doing That|Doing The Other Thing
> @aconnect me=@DOING pickrand(v(LIST.DOINGS),|)
((LOGOUT and reconnect))
> say doing(me)
You say, "Doing That"

Server Differences

On PennMUSH this function is called randword(), though typically pickrand() is set as an alias for it.