Skip to content

Instantly share code, notes, and snippets.

@equaliser
Forked from halfninja/rainbow.scala
Created August 13, 2013 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save equaliser/6220899 to your computer and use it in GitHub Desktop.
Save equaliser/6220899 to your computer and use it in GitHub Desktop.
import Console._
import scala.util.Random
val colours = Seq(BLUE, CYAN, GREEN, MAGENTA, RED, YELLOW)
def rainbow(text: String, colours: Seq[String]) = text.zipWithIndex.map{ case (c,i) => colours(i%colours.size)+c }.mkString + RESET
for (a <- 1 to 20) println(rainbow("Yeah cool colours", Random.shuffle(colours.toList)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment