随笔分类 -  scala

by name parameter & _的用法
摘要:A by-name parameter acts like a def. Scala has a solution to this problem called by-name parameters. By declaring a parameter as a: => A (note that th 阅读全文

posted @ 2017-10-07 16:17 satyrs 阅读(367) 评论(0) 推荐(0)

excption via custom control
摘要:(The other reason (and the one more pertinent to Java developers), is that it provides a nice way to handle common exceptions. Why do I say nice? Firs 阅读全文

posted @ 2017-10-07 15:55 satyrs 阅读(152) 评论(0) 推荐(0)

code snippet-02(scala always to be continue...)
摘要:1() 有无问题 2extends同样可接表达式 3样本类的模型/类成员匹配 4面向表达式的异常 5元组 6Option中get/getOrElse 7PartialFunction 8 阅读全文

posted @ 2017-09-29 20:34 satyrs 阅读(152) 评论(0) 推荐(0)

method visibility
摘要:method access modifier 1 most restrictive access is to mark a method as “object-private.” 只对current instance available,Other instances of the same cla 阅读全文

posted @ 2017-09-28 14:48 satyrs 阅读(148) 评论(0) 推荐(0)

notes for TOUR OF SCALA/efficient scala/programming in scala(scala always to be continue)
摘要:official website https://docs.scala-lang.org/tour/variances.html all codes for testing : https://github.com/yuqingwang15/scala-coding some snippets: h 阅读全文

posted @ 2017-09-24 09:10 satyrs 阅读(225) 评论(0) 推荐(0)

IndexedSeq.scala (source code)
摘要:collection.IndexedSeq的一个trait immutable traitIndexedSeq[+A] extends Seq[A] with GenericTraversableTemplate[A, IndexedSeq] with IndexedSeqLike[A, Index 阅读全文

posted @ 2017-09-24 09:09 satyrs 阅读(182) 评论(0) 推荐(0)

read the file(scala)
摘要:two approaches{io.source / try-finally} scala.io.Source 1 . In Scala shell scripts, where the JVM is started and stopped in a relatively short period 阅读全文

posted @ 2017-09-23 15:45 satyrs 阅读(156) 评论(0) 推荐(0)

for(scala)
摘要:i从1到n变化,对每一个i进行flatMap操作: 从1到i,对每一个j进行filter操作: 如果i+j为prime则选择此j,并对j进行map操作得到(i,j) map: def map[U](f:T=>U): List[U] =this match { case x::xs => f(x):: 阅读全文

posted @ 2017-09-23 06:33 satyrs 阅读(124) 评论(0) 推荐(0)

knn in scala
摘要:nearest neighbor algorithm -- greedy 1开始的点A(不同则答案不同) 2选择cost最小的点D 重复 3最后回到A,加总 knn in scala --intuition /** @author wyq * @version 1.0 * @date Sun Sep 阅读全文

posted @ 2017-09-23 05:46 satyrs 阅读(373) 评论(0) 推荐(0)

collections
摘要:hierarchy of collection classes Iterate-> Seq, Set ,Map Seq->IndexedSeq, LinealSeq Set-> Map-> IndexedSeq ...>Array , String(from java) ->Vector Linea 阅读全文

posted @ 2017-09-23 00:34 satyrs 阅读(145) 评论(0) 推荐(0)

code snippet-01
摘要:more https://github.com/yuqingwang15/scala-coding 01break 用法 02 Symbol定义 03多行输出 04 case 05单例 06loop 阅读全文

posted @ 2017-09-22 23:52 satyrs 阅读(139) 评论(0) 推荐(0)

dependency injection(scala)
摘要:this trait User { def name :String } how to implement/achieve dependency injection (DI) in Scala 1 Cake Pattern This pattern is first explained in Mar 阅读全文

posted @ 2017-09-21 01:41 satyrs 阅读(153) 评论(0) 推荐(0)

=>(scala)
摘要:1Function<n>[A[,B,...],T] :a function that takes parameters of type A[,B...], and returns a value of type T. 2=>() :A function that returns Unit is al 阅读全文

posted @ 2017-09-20 07:01 satyrs 阅读(134) 评论(0) 推荐(0)

trait or abstract class?
摘要:首先你需要重用才需要考虑这个问题。If the behavior will not be reused, then make it a concrete class. 优先使用特质。一个类扩展多个特质是很方便的,但却只能扩展一个抽象类。 If you still do not know, after 阅读全文

posted @ 2017-03-12 15:10 satyrs 阅读(241) 评论(0) 推荐(0)

导航