scala
文章平均质量分 65
lishihaojie
这个作者很懒,什么都没留下…
展开
-
scala 中隐式转换 implicit的应用
下面是一个Rational的类class Rational(n: Int, d: Int) { require(d != 0) private val g = gcd(n.abs, d.abs) val numer: Int = n / g val denom: Int = d / g def this(n: Int) = this(n,翻译 2015-03-06 10:08:29 · 572 阅读 · 0 评论 -
Scala 中的val 与 var 的区别 immutable 与 mutable 的 区别
A balanced attitude for Scala programmersPrefer vals, immutable objects, and methods without side effects.Reach for them first. Use vars, mutable objects, and methods with sideeffects when you翻译 2015-03-05 11:14:54 · 636 阅读 · 0 评论 -
private[spark] class SparkDriverExecutionException 中的[spark]是限制private的范围
下面举个例子新建几个package如下TestClass.scala 中的内容如下package testprivate[test] class TestClass { private var sum = 0 def add(b: Byte): Unit = { sum += b } def checksum(): Int = { retur原创 2015-03-10 16:31:18 · 1003 阅读 · 0 评论 -
scala 实习插入排序(Insert_sort)
1.插入排序的原理,就不说了,直接给个图。2.scala 实先的代码如下:package testobject Insert_Sort { def main(args: Array[String]) = { var intArray = Array(5,2,4,6,1,3,10,9,0) insertSort(intArray)原创 2015-05-29 13:03:00 · 1080 阅读 · 0 评论 -
scala merge_sort排序
1.merge的原理图2.下面给出代码 def merge(intArray: Array[Int], p: Int, q: Int, r: Int): Unit = { val n1 = q - p + 1 val n2 = r - q val MAX =100 var leftArray = new Array[Int](n1原创 2015-05-29 14:14:22 · 862 阅读 · 0 评论