Skip to content

Instantly share code, notes, and snippets.

@chinying
Last active June 24, 2018 04:28
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 chinying/25057975ac1607e9dc28f076cfc9824d to your computer and use it in GitHub Desktop.
Save chinying/25057975ac1607e9dc28f076cfc9824d to your computer and use it in GitHub Desktop.
def normalize(a : Array[Double]) : Array[Double] = {
a.map(v => v/math.sqrt(a.map(x => x*x).reduce(_ + _)))
}
def net(t1: Array[Double], t2: Array[Double]) : Double = {
t1.zip(t2).map(x => x._1 * x._2).reduce(_ + _)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment