Skip to content

Instantly share code, notes, and snippets.

@ykarikos
Created December 6, 2013 20:34
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 ykarikos/7831661 to your computer and use it in GitHub Desktop.
Save ykarikos/7831661 to your computer and use it in GitHub Desktop.
Scala stuff
// Detect primes naively
def prime(x: Int): Option[Int] = if ((2 until x).forall(x % _ != 0)) Some(x) else None
def primeRatio(x: Int): Double = (x - (1 until x).map(prime).count(_ == None)).toDouble/x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment