Pick random element: Difference between revisions

Content deleted Content added
→‎{{header|Bash}}: cleaned it up
Line 70:
<lang Bash>
# borrowed from github.com/search?q=bashnative
 
rand () {
echoprintf -n "$(( $(( ${1} * $(( $(( RANDOM * 100 )) / 32767 )) )) / 100 ))"
}
rand_element () {
local TH;-a th=("$@")
forunset x in "$@"; doth[0]
printf $'%s\n' TH"${th[$(($(rand "${#THth[*]}]="$x)+1))]}";
done
unset TH[0]
echo -n "${TH[$(($(rand "${#TH[*]}")+1))]}"
#" #rosettacode syntax highlighter fix, feel free to remove
}