Skip to content

Instantly share code, notes, and snippets.

@XuefengWu
Created January 12, 2014 15:33
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 XuefengWu/8386108 to your computer and use it in GitHub Desktop.
Save XuefengWu/8386108 to your computer and use it in GitHub Desktop.
(1 to 100 by 2).map(v => v * v).sum
//Parallel
(1 to 100 by 2).par.map(v => v * v).par.sum
//reduce can not Parallel
(1 to 100 by 2).reduce((acc,v) => acc + v * v)
//lazy, read from infinite
Stream.from(0).map(_ * 2 + 1).take(50).reduce((acc,v) => acc + v * v)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment