This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | scala> def Y[A,B](f:((A => B),A) => B,x:A):B = f((y:A) =>Y(f,y),x) | |
| Y: [A,B](f: ((A) => B, A) => B,x: A)B | |
| scala> Y((f:Int => String,n:Int) => n match{case 0 => "ば";case 20 => "あ" + f(n-1);case m =>"ば" + f(n-1);},20) | |
| res32: java.lang.String = あばばばばばばばばばばばばばばばばばばばば | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | scala> Option({ def Y[Int,String](f:((Int => String),Int) => String,x:Int):String = f((y:Int) =>Y(f,y),x);Y( _:((Int => String),Int) => String,_:Int)}).map{y => y((f:Int => String,n:Int) => n match{case 0 => "ば";case 20 => "あ" + f(n-1);case m =>"ば" + f(n-1);},20)}.get | |
| res42: String = あばばばばばばばばばばばばばばばばばばばば | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | scala> class Foo[A](v:A)(implicit val mf:Manifest[A]){ | |
| | def typeParam = mf.erasure | |
| | } | |
| defined class Foo | |
| scala> (new Foo(99)).typeParam | |
| res2: java.lang.Class[_] = int | |
| scala> (new Foo("HOGE")).typeParam | |
| res3: java.lang.Class[_] = class java.lang.String | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public class GenericsTrick { | |
| public static void main(String[] args){ | |
| try{ | |
| System.out.println( | |
| (new GenericsTrick()).createInstance(new Foo[]{}) | |
| ); | |
| }catch(Throwable e){ | |
| e.printStackTrace(); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #### #### | |
| #### #### | |
| #### #### | |
| #### #### | |
| ########################################################################################### | |
| ########################################################################################### | |
| ########################################################################################### | |
| ########################################################################################### | |
| ######### | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. | |
| // Jad home page: http://www.kpdus.com/jad.html | |
| // Decompiler options: packimports(3) | |
| // Source File Name: Main.scala | |
| import scala.Predef$; | |
| import scala.ScalaObject; | |
| import scala.collection.immutable.StringLike; | |
| import scala.runtime.BoxedUnit; | |
| import scala.util.Random$; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Nuclear{ | |
| lazy val radioactivity = { | |
| println( "%sμSv/hだって " format util.Random.nextFloat * 400f) | |
| "(((((((( ;゚Д゚))))))))ガクガクブルブルガタガタブルブル "* util.Random.nextInt(4) | |
| } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | [0]ozaki@mbp $ scala -Xexperimental [~/sandbox/scala/work][0] | |
| Picked up _JAVA_OPTIONS: -Dfile.encoding=UTF-8 | |
| Welcome to Scala version 2.9.0.RC1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_22). | |
| Type in expressions to have them evaluated. | |
| Type :help for more information. | |
| scala> trait DI extends Dynamic { | |
| | def applyDynamic(name:String)(args:Any*):Any = println("Hello, %s %s" format( name, args.mkString("[", ", ", "]"))) | |
| | } | |
| defined trait DI | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // 初期値とstepを指定して永遠にカウントするItrator | |
| class Counter[T:Numeric](init:T = 0,step:T = 1) extends Iterator[T] { | |
| var cnt = init | |
| def hasNext = true | |
| def next = { | |
| cnt = implicitly[Numeric[T]].plus(cnt, step) | |
| cnt | |
| } | |
| // 自分をStreamにする | |
| def asStream = Stream.continually( next ) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | scala> trait ComposableFunction1[-T1, +R] { | |
| | val f: T1 => R | |
| | def >>[A](g:R => A):T1 => A = f andThen g | |
| | def <<[A](g:A => T1):A => R = f compose g | |
| | } | |
| defined trait ComposableFunction1 | |
| scala> implicit def toComposableFunction1[T1,R](func:T1 => R) = new ComposableFunction1[T1,R]{ val f = func } | |
| toComposableFunction1: [T1,R](func: (T1) => R)java.lang.Object with ComposableFunction1[T1,R] |