Pickrand()

From TinyMUX
Jump to navigation Jump to search

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.