Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. # Run Sandbox and connect to it from SSH
  2. ssh root@127.0.0.1 -p 2222
  3.  
  4. # Launch Spark-Shell
  5. spark-shell --master yarn-client --driver-memory 512m --executor-memory 512m
  6.  
  7. # Mutable values
  8. var a: Int = 5
  9. a = a + 1
  10. println(a)
  11.  
  12. # Immutable values
  13. val b: Int = 7
  14. b = b + 1 //Error
  15. println(b)
  16.  
  17. # Type Inference
  18. var c = 9
  19. println(c.getClass)
  20.  
  21. val d = 9.9
  22. println(d.getClass)
  23.  
  24. val e = "Hello"
  25. println(e.getClass)
  26.  
  27. # Functions
  28. def cube(x: Int): Int = {
  29. val x2 = x * x * x
  30. x2
  31. }
  32. cube(3)
  33.  
  34. def cube(x: Int) = x*x*x
  35. cube(4)
  36.  
  37. # Anonymous Functions
  38. val sqr: Int => Int = x => x * x
  39. sqr(2)
  40.  
  41. val thrice: Int => Int = _ * 3
  42. thrice(15)
  43.  
  44. # Collections
  45. val strs = Array("This", "is", "happening")
  46. strs.map(_.reverse)
  47. strs.reduce(_+" "+_)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement