Pickrand()

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 Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Description

FUNCTION: 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()

Examples

> 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.