Scalaé£ãã
Scalaã®åæ¨è«ã«ã¤ã㦠- Togetterã試ãã¦ã¿ã
Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_05).
scala> def id1[T](x : T) = x;
id1: [T](x: T)T
scala> def id2[T] = (x : T) => x;
id2: [T]=> T => T
scala> id1(id1)
<console>:9: error: missing arguments for method id1 in object $iw;
follow this method with `_' if you want to treat it as a partially applied function
id1(id1)
^
scala> id1(id2)
res1: Nothing => Nothing = <function1>
scala> id2(id2)
res3: Nothing => Nothing = <function1>
scala> id2(id2)(1)
<console>:9: error: type mismatch;
found : Int(1)
required: Nothing
id2(id2)(1)
^
id1ã弿°ã«æ¸¡ããªãã®ã¯ã¾ãããããã©ãééããã®ã§è¨é²ã«æ®ãã¦ã
GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help Prelude> let id1 = \x -> x Prelude> let foo = id1 id1 Prelude> :t foo foo :: t -> t
ã¾ãã忍è«ã¨ä¸è¨ã«è¨ã£ã¦ãè¨èªã«ãã£ã¦æ¨è«è¦åã¨ãéãããã¨ããä¾ã¨ãã¦åºãããã£ãã ãã ããããã§ãããã