-
Notifications
You must be signed in to change notification settings - Fork 36
SBE스터디정리
nephilim edited this page Jun 10, 2012
·
1 revision
- 10.1 N-QUeens Problem (p80)
- 10.3.1 flatten Excercise (p84)
- 11.2 whileLoop로 power구현하기 (p91)
- 11.3 Discrete Event Simulation (p92~)
-
12장 Computing with streams
-
13장 Iterators
-
왜 안되나요?
scala> res26.map( _ ) <console>:7: error: missing parameter type for expanded function ((x$1) => res26.map(x$1)) res26.map( _ ) ^ scala> res26.map( x => x ) res28: List[Int] = List(1, 2, 3, 4, 5) scala> res26.map( _:List[Int]) res29: (List[Int]) => List[Int] = <function1>
-
-
14장 Lazy Values
- lazy val 관련 글
- symbols 관련 글 (14장의 Symbols, Symbol과는 무관)
- 15장 Implicit Parameters And Conversions
-
-
괄호 생략을 명확히 할 필요가 있음
scala> def log(headAndTail:String, p:() => Unit):Unit = { | println(headAndTail); | | { | }} log: (headAndTail: String,p: () => Unit)Unit scala> p res8: () => Unit = <function0> scala> p() ME!
-
인자 1개인 경우 괄호 생략?
scala> def p = (x:Int) => { println ("x= " + x); } p: (Int) => Unit scala> p 1 <console>:1: error: ';' expected but integer literal found. p 1 ^
-
함수 정의 형태에 따른 차이, Function0... 객체의 관계를 명확히 하자
scala> def p:()=>Unit = () => { println("##"); } p: () => Unit scala> def p2():Unit = {println("@@@"); } p2: ()Unit scala> val x:()=>Unit = p2 x: () => Unit = <function0> scala> x res32: () => Unit = <function0> scala> x() @@@
-
-
View Bounds의 정의
View bounds <% are weaker than plain bounds <:: A view bounded type parameter clause [A <% T] only specifies that the bounded type A must be convertible to the bound type T, using an **implicit conversion**. -- Scala By Example, p55 --
-
스칼라 예외와 자바 예외의 차이
- PIS p161 note 참고
- PIS p598
-
View Bounds < Upper Bounds ?
scala> class Parent defined class Parent scala> class Child extends Parent defined class Child scala> def printf[A <% Parent](obj:A):Unit = { | println( obj + "!!!" ); | } printf: [A](obj: A)(implicit evidence$1: (A) => Parent)Unit
-
Trait
-
PIS 12, 20장 참고
-
Abstract vals (PIS 20.3)
scala> trait TestLinearization { | val message:String | def print():Unit = { | println(message) | } | } defined trait TestLinearization scala> object Test extends TestLinearization { | val message = "hi" | } defined module Test scala> Test.print hi
-
override
def
withval
? -
Abstract vars (PIS 20.4)
-
-
DisjointType ('Int or String' Type) - Infix Types
// This type Foo[Bar,Baz] // is the same as type Bar Foo Baz
-
과제 Persistent DSL 만들고 공유하기
- SBT
-
-
def, val 차이
scala> def a:Int = { println("A"); 3 } a: Int scala> a A res11: Int = 3 scala> a A res12: Int = 3 scala> val a = { println("A");3} A a: Int = 3 scala> a res23: Int = 3 scala> a res24: Int = 3
-
함수 정리
scala> val f1:(Int,Int)=>String = (a,b)=> { a + b + "!" } f1: (Int, Int) => String = <function2> scala> val f2:Function2[Int,Int,String] = f1 f2: (Int, Int) => String = <function2> scala> f2(3,4) res39: String = 7! scala> val f3 = new Function2[Int,Int,String] { | def apply(x:Int, y:Int) = { x + y + "!" } | } f3: java.lang.Object with (Int, Int) => String = <function2> scala> f3(3,4) res40: String = 7!
- (A)=>B == Function1[A,B]
- 함수도 결국 (객체의) 인스턴스
- 함수를 실행하려면 ()사용
-
Scala로 control structure를 정의해 JDBC loop 구현 예
- Beginning Scala p109 참고
- Hindley-Milner 에 대한 설명 링크