Last active
December 12, 2015 01:18
-
-
Save migue/4690167 to your computer and use it in GitHub Desktop.
Small script to choose a random element in a list. It is used to raffle conference tickets among the MadridJUG community members
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.util.Random | |
def winner(members:List[String]):String = { | |
new Random(System.currentTimeMillis()).shuffle(members).head | |
} | |
// write the names of all the members involved in the raffle | |
val qcon = List("Jorge Baez", "Daniel Jiménez", "Gonzalo Gómez", "Jorge Nota", "Jose Ignacio Dominguez", "Daniel Hernández", "Manuel Carrasco") | |
println("The winner of the QCon London ticket is " + winner(qcon)) | |
val devoxx = List("Daniel Jiménez", "Gonzalo Gómez", "Jorge Nota", "Jose Ignacio Dominguez", "Daniel Hernández", "Manuel Carrasco", "Jorge Baez") | |
println("The winner of the Devoxx UK ticket is " + winner(devoxx)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment