自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(12)
  • 资源 (8)
  • 收藏
  • 关注

原创 scala随机数生成,生成一组不重复随机数算法

scala随机数生成函数(new util.Random).nextInt(n) 返回一个0-n(不包括n) 的随机数比如scala> (new util.Random).nextInt(3)res7: Int = 1返回一个[0, 2]的随机数scala生成一组不重复的随机数1、循环获取随机数,再到 list中找,如果没有则添加def randomNew(n:Int)=

2015-09-30 16:28:59 25309

原创 P22 (*) Create a list containing all integers within a given range

Example:scala> range(4, 9)res0: List[Int] = List(4, 5, 6, 7, 8, 9)def range(n1:Int,n2:Int)={ List(n1 to n2)}看了下答案,原来可以直接用List.range()递归解法def range(start: Int, end: Int): List[Int] = if (end <

2015-09-30 13:45:59 464

原创 P20 (*) P21 (*)Remove the Kth element from a list;Insert an element at a given position into a list.

Return the list and the removed element in a Tuple. Elements are numbered from 0.Example:scala> removeAt(1, List('a, 'b, 'c, 'd))res0: (List[Symbol], Symbol) = (List('a, 'c, 'd),'b)def removeAt

2015-09-30 11:56:35 572

原创 P19 (**) Rotate a list N places to the left.

Examples:scala> rotate(3, List('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k))res0: List[Symbol] = List('d, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'a, 'b, 'c)scala> rotate(-2, List('a, 'b, 'c, 'd, 'e, 'f, 'g,

2015-09-29 17:40:25 388

原创 P18 (**) Extract a slice from a list

Given two indices, I and K, the slice is the list containing the elements from and including the Ith element up to but not including the Kth element of the original list. Start counting the elemen

2015-09-29 17:13:06 388

原创 P16 (**)-P17 (*) Drop every Nth element from a list;Split a list into two parts.

16scala> drop(3, List('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k))res0: List[Symbol] = List('a, 'b, 'd, 'e, 'g, 'h, 'j, 'k)参考答案:其中关于zip 和filter的用法见http://blog.csdn.net/springlustre/article/deta

2015-09-29 16:33:40 485

原创 P14 (*) -P15 (**)Duplicate the elements of a list,Duplicate the elements of a list a given number of

scala> duplicate(List('a, 'b, 'c, 'c, 'd))res0: List[Symbol] = List('a, 'a, 'b, 'b, 'c, 'c, 'c, 'c, 'd, 'd)scala> duplicateN(3, List('a, 'b, 'c, 'c, 'd))res0: List[Symbol] = List('a, 'a, 'a, 'b, 'b,

2015-09-29 15:58:21 419

原创 P13 (**) Run-length encoding of a list (direct solution).

Implement the so-called run-length encoding data compression method directly. I.e. don't use other methods you've written (like P09's pack); do all the work directly.Example:scala> encodeDirect(

2015-09-29 15:44:15 576

原创 P12 (**) Decode a run-length encoded list.

Given a run-length code list generated as specified in problem P10, construct its uncompressed version.Example:scala> decode(List((4, 'a), (1, 'b), (2, 'c), (2, 'a), (1, 'd), (4, 'e)))res0: Lis

2015-09-29 15:19:33 517

原创 P11 (*) Modified run-length encoding.

Modify the result of problem P10 in such a way that if an element has no duplicates it is simply copied into the result list. Only elements with duplicates are transferred as (N, E) terms.Example:

2015-09-29 14:31:06 475

原创 scala中的函数组合器map,foreach,flatmap,flatten,filter,zip等用法

1、mapmap方法可以将某个函数应用到集合中的每个元素并产出其结果的集合,比如val names=List("a","b","c")可以用names.map(_.toUpperCase)得到List("A","B","C")2、foreachforeach和map相似,只不过它没有返回值,foreach只要是为了对参数进行作用。比如 nam

2015-09-29 12:37:49 18338

原创 1、Find the last element of a list.

Example:scala> last(List(1, 1, 2, 3, 5, 8))res0: Int = 8最直接的办法def s1(list:List[Any])={ list.last}def main(args: Array[String]) { println(s1(List(1,2,3,4,5)))}

2015-09-24 19:50:06 456

数学建模常用算法

数学建模常用的算法,包括神经网络,灰色理论之类的

2015-01-26

javaee的网上书店程序,有一定参考价值

用javaee编写的网上书店程序,用的Mysql数据库,对于初学者有一定的参考价值

2014-05-31

MSP430G2553四线驱动1602

MSP430G2553四线驱动1602显示屏进行显示

2014-05-04

MSP430G2553测频率12864显示完整程序

一个比较完整的msp430G2553的频率计,用12864显示,程序比较完善,实用性较强,参考价值很大

2014-05-04

MSP430 测频的程序

从pudn档的一个程序,msp430测频率的代码

2014-05-04

msp430g2553测频程序

msp430g2553测频的程序,对初学者有一定的帮助,适合刚刚接触的同学

2014-05-04

msp430g2553测频率

msp430g2553简易测频计,有一定的参考价值

2014-05-04

MyEclipse2013破解工具

之前的破解工具都是破解MyEclipse10.X的,这是MyEclipse2013破解工具,本人亲测,破解步骤可见http://blog.csdn.net/springlustre/article/details/20720103

2014-03-08

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除