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(i:Int) extends DelayedInit{ | |
| | println("aaaaaa:" + i ) | |
| | val d = new java.util.Date | |
| | println( d ) | |
| | | |
| | def delayedInit(x: => Unit){ | |
| | println("delayed init") | |
| | println("-" * 80) | |
| | x | 
  
    
      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
    
  
  
    
  | package com.yuroyoro.util.collection | |
| import scala.collection.{Iterable, IterableLike} | |
| trait TypedIterableProxy[A, Repr<: Iterable[A]] extends Iterable[A] with IterableLike[A, Repr]{ | |
| import scala.collection.generic.CanBuildFrom | |
| import scala.collection.mutable.{ListBuffer, Builder} | |
| val self:Iterable[A] | |
| def newTo(from:Iterable[A]):Repr | |
| def iterator = self.iterator | 
  
    
      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
    
  
  
    
  | # Sleep sortに対抗してアホなソートアルゴリズム作った。 | |
| # いちおうsleepはしない | |
| # 負の数が含まれていると対応できない(これはちょっと改良すればできるが) | |
| module ArrayIndexSort | |
| def self.sort(xs) | |
| Array.new(xs.max + 1){Array.new()}.tap{|ys| xs.each{|x| ys[x] << x}}.flatten! | |
| end | |
| end | |
| p ArrayIndexSort.sort([23, 1, 53, 3, 1, 3, 6, 13, 3, 6, 1, 3, 7, 1, 3, 6, 1, 3, 7, 133, 63, 137]) | 
  
    
      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
    
  
  
    
  | import scala.tools.nsc.Settings | |
| import java.io.{PrintWriter, ByteArrayOutputStream, FileOutputStream} | |
| import scala.tools.nsc.interpreter.{ IMain, Results => IR } | |
| object Eval extends App{ | |
| val settings = new Settings | |
| settings.usejavacp.value = true | |
| // interpret one line | 
  
    
      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
    
  
  
    
  | import scala.tools.nsc.interpreter._ | |
| import scala.tools.nsc.Settings | |
| import java.io.{PrintWriter, FileOutputStream} | |
| object MyREPL extends App{ | |
| val settings = new Settings | |
| val out = new PrintWriter(new FileOutputStream("output.txt")) | |
| val iLoop = new ILoop(Console.in, out) | |
| iLoop process settings | |
| } | 
  
    
      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
    
  
  
    
  | import scala.tools.nsc.Settings | |
| import java.io.{PrintWriter, ByteArrayOutputStream, FileOutputStream} | |
| case class EvalException (msg: String, cause:Throwable = null) extends | |
| RuntimeException(msg, cause) | |
| class Evaluator( val settings:Settings = new Settings ){ | |
| import scala.tools.nsc.interpreter.{ IMain, Results => IR } | |
| settings.usejavacp.value = true | 
  
    
      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
    
  
  
    
  | /* | |
| OptManifest[A]とかNoManifestとかの話をしよう | |
| OptManifest[A]ってのは、Manifestがあるかないか分からない場合に使う。 | |
| 値があるかないかをOption[A]で表すように、 | |
| 型パラメータAに対するManifestがあるかないかわからない場合はOptManifest[A]をつかう | |
| Manifestの継承関係は以下の通り。OptManifestは全てのManifestの親traitになっている。 | |
| trait OptManifest [+T] | |
| object NoManifest extends OptManifest[Nothing] | 
  
    
      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 library can be used to color/uncolor strings using ANSI escape sequences. | |
| * | |
| * To implementation, referenced Ruby's "Term::ANSIColor"(http://term-ansicolor.rubyforge.org) | |
| * | |
| * NOTE | |
| * this version's implementation is using Dynamic trait and applyDynamic. | |
| * "applyDynamic" is not supported yet. | |
| * to enable this feature, you should specify -Xexperimental option when running scala/scalac command. | |
| * | 
  
    
      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 retry[T](p: => Boolean)(f: => T):T = | |
| | try{ f } catch { case e => if(p) retry(p)(f) else throw e } | |
| retry: [T](p: => Boolean)(f: => T)T | |
| scala> retry( util.Random.nextInt(3) == 0 ){ println("trying..."); "a".toInt } | |
| trying... | |
| java.lang.NumberFormatException: For input string: "a" | |
| at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) | |
| at java.lang.Integer.parseInt(Integer.java:449) | 
  
    
      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
    
  
  
    
  | import java.io.File | |
| import scala.io.Source | |
| import scala.util.matching.Regex | |
| import scala.util.parsing.combinator._ | |
| import scala.util.parsing.input.{Position, NoPosition} | |
| sealed abstract class Insn extends ( CED => CED ){ | |
| val pos:Position | |
| } | |
| case class App( m:Int, n:Int, pos:Position ) extends Insn{ |