scala混合了面向对象和函数式的特征。在函数式的编程语言中,函数是可以像其他的数据类型一样被传递和操作。这对于想将详细动作传入给算法时变得非常有用。importscala.math._
valfun=ceil_/从技术上将_的作用是将ceil方法变成了函数
res=fun(num)/num=3.14,res=4
Array(3.14,..
分类:
其他好文 时间:
2014-09-18 16:45:25
阅读次数:
188
随着移动设备用户数量不断增长,山寨App数量也如雨后春笋般层出不穷,一项专门针对Google Play商店前50大热门免费App的调查显示,高达80%的应用程序有其对应的山寨版本,其中小工具、影片及财经类别App100%都有假冒版本。...
分类:
移动开发 时间:
2014-09-18 14:56:54
阅读次数:
244
最近,安卓出现了一个严重的诈骗事件——安卓官方商店Google Play最佳付费应用榜上的App Virus Shield,居然是一款诈骗应用!据悉,这款诈骗应用Virus Shield自称是一款能够保护手机免受病毒恶意软件侵害的安全应用,同时能够提高手机运行速度,并具有广告清除等功能。该应用在Google Play商店售价为3.99美元,下载量过万,拥有4.7星的评价,雄踞Google Play商店付费榜榜首,有1700位用户给出了评价,2607位用户点击了“推荐”按钮。...
分类:
移动开发 时间:
2014-09-17 13:43:52
阅读次数:
222
A New Stone GameTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 4177Accepted: 2227DescriptionAlice and Bob decide to play a new stone game.At...
分类:
其他好文 时间:
2014-09-16 02:41:29
阅读次数:
280
鸭子类型:“当看到一只鸟走起来像鸭子、游泳起来像鸭子、叫起来也像鸭子,那么这只鸟就可以被称为鸭子。” 一般在动态语言里面才有,因为静态语言是强类型的,会在编译期检查类型,很难实现。但是Scala作为一门s...
分类:
其他好文 时间:
2014-09-15 23:00:39
阅读次数:
415
Problem Description
Here is a game for two players. The rule of the game is described below:
● In the beginning of the game, there are a lot of piles of beads.
● Players take turns to play. ...
分类:
其他好文 时间:
2014-09-15 21:21:29
阅读次数:
202
单例对象scala没有静态方法和静态字段。scala使用object实现,object定义了单个实例。1 object Accounts {2 private var lastNumber = 0;3 def newUniqueNumber() = { lastNumber += 1; la...
分类:
其他好文 时间:
2014-09-15 17:20:29
阅读次数:
192
简单类和无参方法:1 class Counter {2 private var value = 0; //必须初始化字段3 def increment() = value += 1 //方法默认是公有的4 def current = value5 }使用:1 val counter1 =...
分类:
其他好文 时间:
2014-09-15 17:16:29
阅读次数:
161
Map构造Map不可变:val map = Map("sa" -> 1, "s" -> 2)map("sa") = 3 // errorval emptyMap = newscala.collection.immutable.HashMap[String, Int]可变:val map2 = sca...
分类:
其他好文 时间:
2014-09-15 14:07:08
阅读次数:
252
定长数组:val nums = new Array[Int](10)变长数组:val b = new ArrayBuffer[Int] 或 ArrayBuffer[Int]()b.+=1b.+= (2, 3, 4)b.++= Array(5, 6, 7, 8)b.trimEnd(3)b.insert...
分类:
其他好文 时间:
2014-09-15 10:02:38
阅读次数:
201